6. 函数参数 与 展开运算符
1.函数参数
a.
function test(word){ console.log(word); } test('hello word');
b.
function test(word = 'hello world'){ console.log(word); } test();
2. 展开运算符
a.
let args = [1,2,3]; function test(){ console.log(args); } test.apply(null, args); // 旧的用法 test(...args); // 新的用法
b. 多参数
let args1 = [1,2,3]; let args = [4,5,6]; function test(){ console.log(args1+','+args); } test(...args1, ...args); // 新的用法