4.3.2. Evaluating Variables¶ code example

Example 1: 4.3.2. Evaluating Variables¶

/*Like values, variables also have types. We determine the type of a 
variable the same way we determine the type of a value, using typeof.*/

let message = "What's up, Doc?";
let n = 17;
let pi = 3.14159;

console.log(typeof message);
console.log(typeof n);
console.log(typeof pi);

//string
//number
//number

Example 2: 4.3.2. Evaluating Variables¶

/*When we refer to a variable name, we are evaluating the variable. 
The effect is just as if the value of the variable is substituted 
for the variable name in the code when executed.*/

let message = "What's up, Doc?";
let n = 17;
let pi = 3.14159;

console.log(message);
console.log(n);
console.log(pi);

//What's up, Doc?
//17
//3.14159

Example 3: 4.3.2. Evaluating Variables¶

/*After a variable has been created, it may be used later in a program 
anywhere a value may be used. For example, console.log prints a value, 
we can also give console.log a variable.*/

//These two examples have the exact same output.
console.log("Hello, World!");

let message = "Hello, World!";
console.log(message);