+ 2

does return; statement return values?

does return; statement return values? how? can you pls tell me idk what is return statement.

1st Nov 2022, 7:08 AM
Fami-Coder
Fami-Coder - avatar
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”
1st Nov 2022, 7:58 AM
Muhammad Ali
Muhammad Ali - avatar
+ 4
no 'return' will stop further execution return 'abc' will return value 'abc' back to the function
1st Nov 2022, 7:34 AM
AÍąJ
AÍąJ - avatar
+ 1
understandable 😊
2nd Nov 2022, 2:04 AM
Fami-Coder
Fami-Coder - avatar