This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function smile(isHappy) { | |
if (isHappy) { | |
var smiling = 'I am happy!'; | |
} else { | |
var sad = 'I am sad!'; | |
console.log(smiling); | |
} | |
} | |
smile(false); // undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function smile(isHappy) { | |
var smiling; | |
var sad; | |
if (isHappy) { | |
smiling = 'I am happy!'; | |
} else { | |
sad = 'I am sad!'; | |
console.log(smiling); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function smile(isHappy) { | |
if (isHappy) { | |
const smiling = 'I am happy!'; | |
} else { | |
const sad = 'I am sad!'; | |
console.log(smiling); | |
} | |
} | |
smile(false); // ReferenceError: smiling is not defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var name = 'Valery Melou'; | |
var message = 'Hello! My name is ' + name + '.'; | |
console.log(message); // Hello! My name is Valery Melou. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const name = 'John Doe'; | |
const message = `Hello! My name is ${name}.`; | |
console.log(message); // Hello! My name is John Doe. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a = 10; | |
let b = 20; | |
let result = `The sum of ${a} and ${b} is ${a + b}.` | |
console.log(result); // The sum of 10 and 20 is 30. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var coordinates = [10, 30, 5]; | |
var x = coordinates[0]; | |
var y = coordinates[1]; | |
var z = coordinates[2]; | |
console.log(x, y, z); // 10 30 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const coordinates = [10, 30, 5]; | |
const [x, y, z] = coordinates; | |
console.log(x, y, z); // 10 30 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var person = { | |
firstName: "John", | |
lastName: "Doe", | |
age: 15 | |
}; | |
var firstName = person.firstName; | |
var lastName = person.lastName; | |
var age = person.age; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let person = { | |
firstName: "John", | |
lastName: "Doe", | |
age: 15 | |
}; | |
let {firstName, lastName, age} = person; | |
console.log(firstName, lastName, age); // John Doe 15 |
OlderNewer