duplicate parameter not allowed in strict mode❗️

in "strict mode", duplicate parameters not allowed❗️

JSerrorSyntaxError ⟩ duplicate parameter name

no errors in sloppy mode

console.log("Howdy");        // Howdy
sayHi("Hello", "Hi");        // Hi

function sayHi(x, x) {       // duplicate parameters
    console.log(x);
}

⭐️ deplicate parameters not allowed in strict mode.

console.log("Howdy");        // ⭐️ never runs❗

// ⛔ SyntaxError: 
//    Duplicate parameter name not allowed in this context
//                ↓
function sayHi(x, x) {       // ⭐️ compile-time error
    "use strict";            // ⭐️ strict mode
    console.log(x);
}

Last updated