10 3 2 defining and calling

Solutions on MaxInterview for 10 3 2 defining and calling by the best coders in the world

showing results for - "10 3 2 defining and calling"
Stefano
22 Jun 2016
1/*When we define a function, we are making it available for later use. 
2The function does not execute when it is defined; it must be called in 
3order to execute. This is not only a common point of confusion for new 
4programmers, but can also be the source of logic errors in programs.
5
6Let's see how this works explicitly.
7
8What happens if we define a function without calling it?*/
9
10function sayHello() {
11   console.log("Hello, World!");
12}
13
14//What is printed when this program runs?
15
16//In order for a function to run, it must be explicitly called.
17
18function sayHello() {
19   console.log("Hello, World!");
20}
21
22sayHello();
23
24//Hello, World!
similar questions
queries leading to this page
10 3 2 defining and calling