argumentsを配列にする
Array.prototype.sliceを使うことで手軽に配列にできる
元来argumentsは「数字を添字に持つオブジェクト型」なので配列のメソッドは使えない
jsなら args=Array.prototype.slice.call(arguments);
coffeeなら args=Array::slice.call arguments
code:help.txt
引数を配列(にする|として使う)
ES2015ではspread operatorを使うとできる
code:js
function sum (...args) {
return args.reduce((a,b) => a + b) // 普通の配列になる
}
function foo (a, b, c, ...options)とかもできる