Curious about the value of an ignored parameter in JS? Imagine a function that requires 2 values as parameters, but you only provide one during the call. What happens to the other parameter? You might think it's undefined, but the code below only shows "1."
var test = function(par1, par2){
document.write(par1.toString());
document.write(par2.toString());
if(typeof par2 === "undefined"){
document.write('undefined');
}
};
test(1);
If you tweak the code slightly like this:
var test = function(par1, par2){
document.write(par1.toString());
document.write(par2);
if(par2 === undefined){
document.write('undefined');
}
};
test(1);