Course Content
Introduction to JavaScript
The main property of the function is to return a value.
The space of the function is deleted after its execution, and you will very rarely output information to the console through the function.
With the help of the return
keyword, the value return operation will be performed, and the function will finish its execution:
You can see above that function calling (add(25, 30)
) was replaced by the literal 55
(25 + 30), which was after the return
keyword.
Note
The function has completed its execution and returns a value that becomes a literal at the point of call, and the function space disappears.
It is also necessary to understand that the keyword return
ends the execution of the function. All the code after the return
will not be executed:
You can see that the console.log()
operations were not executed.
Section 6.
Chapter 5