+ 2
does return; statement return values?
does return; statement return values? how? can you pls tell me idk what is return statement.
3 odpowiedzi
+ 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 😊