I always thought, that new lines in JS sourcecode doesn't matter. Why new lines do matter sometimes?
Error:
function x(y)
{
return
{ y : y,
z : y*2
}
}
console.info(x(5).z);
Throws a SyntaxError: missing ; before statement at z : y*2
(pointing to the :
)
But this is working:
function x(y)
{
return (
{ y : y,
z : y*2
} )
}
console.info(x(5).z);
shows 10
This is also working:
function x(y)
{
return {
y : y,
z : y*2
}
}
console.info(x(5).z);