I was reverse engineering a jQuery plugin and found a peculiar function definition.
function myFunction(value, undefined){
...
}
Of course, this works but similar declarations like
function myFunction(value, null) {
...
}
OR
function myFunction(value, 5) {
...
}
do not work.
The initial declaration where the parameter is undefined
works like a default parameter value (refer the snippet below). Can someone point to this phenomenon in ECMA6 specification. I have clue on what to even search for.
function strange (value, undefined) {
document.getElementById("output").innerHTML += "<br/>" + "- " + arguments[1];
}
strange(5,6);
strange(5);
<div id="output"></div>