+ 2
does return; statement return values?
does return; statement return values? how? can you pls tell me idk what is return statement.
3 Answers
+ 3
does return; statement return values?
No, âreturn;â will return nothing to the function and the code after it wonât be executed. Itâs a JS reserved keyword to exit out of function.
To get something out of the function. You use return.
E.g:
function foo(){
return âbarâ;
}
var bar = foo();
In the above example. We created a function which returns âbarâ, and outside the function. We called it on var named âbarâ. Now the VARIABLE âbarâ has âbarâ in it which was returned from the function âfooâ
+ 4
no 'return' will stop further execution
return 'abc' will return value 'abc' back to the function
+ 1
understandable đ