Math.min() accepts a set of values. When you would like to find the minimum value of an array, you can use the following trick:
Function#apply receives an object for "text" and arguments in array.
On the other hand Ruby has a feature of this issue as a syntactic sugar.
var a = new A(x);
You may want to abbreviate the keyword "new" like
var a = A(x);
You can provide such class with the following trick.
On the other hand, Ruby has separate namespace, so you can re-write the following code
a = A.new(x)
def A(x); A.new(x); end a = A(x)
cloning an array
array2 = array.slice(0);
array2 = array.dup
The JS version is actually not just cloning but converts arguments object to array, so you can regard
Array#slice in JS as the combination of
to_a in Ruby.