Answers for "10.3.2. Defining and Calling"

0

10.3.2. Defining and Calling

/*When we define a function, we are making it available for later use. 
The function does not execute when it is defined; it must be called in 
order to execute. This is not only a common point of confusion for new 
programmers, but can also be the source of logic errors in programs.

Let's see how this works explicitly.

What happens if we define a function without calling it?*/

function sayHello() {
   console.log("Hello, World!");
}

//What is printed when this program runs?

//In order for a function to run, it must be explicitly called.

function sayHello() {
   console.log("Hello, World!");
}

sayHello();

//Hello, World!
Posted by: Guest on June-23-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language