Consider the following JavaScript:
function correct()
{
return 15;
}
function wrong()
{
return
15;
}
console.log("correct() called : "+correct());
console.log("wrong() called : "+wrong());
The correct()
method in the above code snippet returns the correct value which is 15
in this case. The wrong()
method, however returns undefined
. Such is not the case with the most other languages.
The following function is however correct and returns the correct value.
function wrong()
{
return(
15);
}
If the syntax is wrong, it should issue some compiler error but it doesn't. Why does this happen?