This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f(x, x, …rest) {} | |
Syntax Error: duplicate parameter name (Rule 1.A) | |
function f(x, {a:x, b:y}) {} | |
Syntax Error: duplicate parameter name (Rule 1.A) | |
function f([x]) { let x; } | |
Syntax Error: redeclaration of parameter x (Rule 1.B) | |
function f([x]) { var x; } | |
Syntax Error: redeclaration of parameter x (Rule 1.B) | |
function f([x]) { {var x;} } | |
Syntax Error: redeclaration of parameter x using hoisted var (Rule 1.B) | |
function f([x]) { {let x;} } | |
Valid, redeclaration is in inner block | |
function f([x]) { function x(){} } | |
Syntax Error: redeclaration of parameter x (Rule 1.B) | |
function f([x]) { class x {} } | |
Syntax Error: redeclaration of parameter x (Rule 1.B) | |
function f(x, y=x) {} | |
Valid, x has been initialized when y's default value expression is evaluated. | |
function f(x=y, y) {} | |
Runtime: ReferenceError exception y not initialized (Rule 2) | |
const a = "A"; | |
function f(x=a) {} | |
Valid | |
function f(x=a) { var a;} | |
Runtime: ReferenceError a not yet initialized (Rule 2.A) | |
function f(x=a) { const a = "A";} | |
Runtime: ReferenceError a not yet initialized (Rule 2.A) | |
function a() {return "A";} | |
function f(x=a()) {} | |
Valid, a is initialized in surrounding scope, at time of parameter default value initialization. | |
function f(x=a()) { function a() { return "A"; } } | |
Runtime: ReferenceError a not yet initialized (Rule 2.A) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(6) | |
function f(x, y = 7) { | |
... | |
} | |
<===> | |
(5) | |
function f(x, y) { | |
let x1 = x; | |
let y1 = y ?? 7; | |
(5) | |
return (function(x, y) { | |
... | |
}).call(this, x1, y1); | |
} | |
WH: (whiteboard) | |
function f(x, x=7, z=x) { | |
let x1 = x; | |
let x2 = x ?? 7; | |
let z1 = z ?? which x?; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment