I got an unexpected return value "undefined" from function 'fnExample1' if I indent code like this :
function fnExample1() {
return
1;
}
I have made this simple example : Example jsfiddle
Thanks.
I got an unexpected return value "undefined" from function 'fnExample1' if I indent code like this :
function fnExample1() {
return
1;
}
I have made this simple example : Example jsfiddle
Thanks.
write return
and 1
in one line
function fnExample1() {
return 1;
}
The reason why your code returns undefined is javascript's "semicolon insertion", where a semicolon is inserted after return
, and 1
is considered another statement (which is not executed)