return
The primary purpose of a function is to return a value.
The function's space is deleted after its execution, and you rarely output information directly from the function to the console.
The return
keyword is used to perform the value return operation, and it signifies the end of the function's execution:
In the example above, you can see that the function call (add(25, 30)
) is replaced by the value 55
(25 + 30) after the return
keyword.
Note
The function completes its execution and returns a value at the point of call, and the function's space is cleared.
It's also essential to understand that the return
keyword terminates the execution of the function. Any code after the return
statement will not be executed:
The console.log()
statements after the return
statement were not executed.
Tudo estava claro?
Conteúdo do Curso
Introduction to JavaScript
4. Conditional Statements
Introduction to JavaScript
return
The primary purpose of a function is to return a value.
The function's space is deleted after its execution, and you rarely output information directly from the function to the console.
The return
keyword is used to perform the value return operation, and it signifies the end of the function's execution:
In the example above, you can see that the function call (add(25, 30)
) is replaced by the value 55
(25 + 30) after the return
keyword.
Note
The function completes its execution and returns a value at the point of call, and the function's space is cleared.
It's also essential to understand that the return
keyword terminates the execution of the function. Any code after the return
statement will not be executed:
The console.log()
statements after the return
statement were not executed.
Tudo estava claro?