- 1

When JavaScript reaches a return statement, the function stops executing. Please explain its full meaning.

if possible please give any example

26th Apr 2017, 2:25 AM
Manoj singh jalal
Manoj singh jalal - avatar
3 Answers
+ 6
If I write program that have return the greater value for example: var n = age(2,1) function age(x,y){ if(x>y){ return x; }return y; } that mean if x>y : this function already have return value.And it can stop the process. Else : the function does not read if statement and it have return y next. This function is already return y and stop the process.
26th Apr 2017, 2:46 AM
Nithiwat
Nithiwat - avatar
0
thanks sir
26th Apr 2017, 2:40 AM
Manoj singh jalal
Manoj singh jalal - avatar
- 1
An analogy: when you call a function, you want it to do some actions. When the definition of the function reaches a return statement, it says "hey, the job is done, and this is the answer you asked me for".
26th Apr 2017, 5:27 AM
Álvaro