arguments
arguments オブジェクトは配列として使用できますが、forEach、sort、filter、map などの JavaScript 関数をサポートしていません。
//コード
function chktype() {
console.log(typeof arguments); //typeof
console.log(Array.isArray(arguments)); //配列かどうか?
console.log(arguments);
console.log(arguments[0]);
}
chktype('1','2','3');
argumentsを配列に変換
//ES6コード
var args = [...arguments];
直接ぶちこんでもOK
function func(...args) {
console.log(args);
console.log(args[0]);
}
func(1,2,3);
//ES6コード
Array.from(arguments)
//ES5コード
var args = Array.prototype.slice.call(arguments);
//短縮系
var args = [].slice.call(arguments);
参考:参考リンク
解説。この文章はダミーです。文字の大きさ、量、字間、行間等を確認するために入れています。レイアウトを確認するための文章ですので意味はありません。
//コード