Skip to content

ES5 语法

使用 arguments 变量,剪头函数中没有 arguments

js
function test(){
    console.log(arguments);
}
test(1,2,3,4,5);

ES6

  1. 使用 rest 参数

    js
    let test = (...options) => {
        console.log(options);
    }
    test(1,2,3,4,5);

  2. rest 参数必须放在形参列表的末尾

    js
    let test = (a,b,...options) => {
        console.log(a,b,options);
    }
    test(1,2,3,4,5);

基于 MIT 许可发布