deplicate parameters

🚧 施工中

JSobjectsbuilt-inFunctionparameter ⟩ duplicate parameters

in non-strict mode, JavaScript allows a function to have several parameters with the same name, where later parameters shadow earlier parameters.

⭐️ duplicate parameters not allowed in strict mode.

function g(x, y, x, y) {
    //           ^
    // ⛔ SyntaxError: 
    //    Duplicate parameter name not allowed in this context
    //    (note: this is a compile-time error)
    
    'use strict';        // ⭐️ strict mode
    
    return [x, y];
}

👉 duplicate parameter not allowed in strict mode❗️

Last updated