Sign up for Free !!
World's first open source developer community with
Ticketing System
function arrayFromValue(item) { return [item]; } arrayFromValue(10); // => ???
During programming it's common to make mistakes here and there,
but if we make mistake like this, like missing a whole line between the return keyword and [item] expression.
The newline makes the JavaScript automatically insert a semicolon between return and [item] expression.
so the written code will be added with the semicolon inserted after return like the code below,
function arrayFromValue(item)
{
return;
[item];
}
arrayFromValue(10); // It's undefined
return inside the function makes it return undefined.
So arrayFromValue(10) evaluates to undefined.
Please Login/Register to write your answer !!!
During programming it's common to make mistakes here and there,
but if we make mistake like this, like missing a whole line between the return keyword and [item] expression.
The newline makes the JavaScript automatically insert a semicolon between return and [item] expression.
so the written code will be added with the semicolon inserted after return like the code below,
function arrayFromValue(item)
{
return;
[item];
}
arrayFromValue(10); // It's undefined
return inside the function makes it return undefined.
So arrayFromValue(10) evaluates to undefined.