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 organizations = ['Pyke', 'Black Sun', 'Kanjiklub', 'Crimson Dawn']; | |
const [firstGang, secondGang, thirdGang, fourthGang] = organizations; | |
console.log(firstGang); // Outputs 'Pyke' | |
console.log(secondGang); // Outputs 'Black Sun' | |
console.log(thirdGang); // Outputs 'Kanjiklub' | |
console.log(fourthGang); // Outputs 'Crimson Dawn' |
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
// To call them by their first names without the lastname | |
// we have to destructure this object. | |
//This object describes what we perceive of each child | |
//Object name - Lastname, Property name - firstname | |
let ifebhor = { | |
carol: "rude", | |
damian: "caring", | |
mac: "handsome", | |
flora: "cute", |
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 carol, damian, aave; | |
//notice the parentheses around the statement | |
({carol, damian, aave} = ifebhor); | |
console.log("Carol is so " + carol + | |
" but I love Damian he's " | |
+ damian + " and Aave is the " | |
+ aave +"."); |
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
//If I am a new student who just got | |
//introduced to some of the siblings | |
//I might just give them some attributes | |
//based on their physical appearance. | |
let ifebhor = { carol: "rude", | |
damian: "caring" | |
}; | |
//we just pick a property for each | |
//of them which will be overriden |
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 ifebhor = { | |
carol: "rude", | |
damian: "caring", | |
mac: "handsome", | |
flora: "cute", | |
aave: "class bully" | |
} | |
//mac's property can now be referenced using playboy. | |
let {mac : playboy} = ifebhor; |
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
Damian = {age: 4, | |
hobby: "reading", | |
scores:{maths: 83, | |
english: 79, | |
writing: 44 | |
} | |
} | |
//it looks very similar to the basic destructuring syntax | |
//however you should note the nested object names are not assigned |
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 ifebhor = { | |
carol: "rude", | |
damian: "caring", | |
mac: "handsome", | |
flora: "cute", | |
aave: "class bully" | |
} | |
// If Flora repeats a class. I'll have to remove her name from the object a way | |
//to do that would be to use the rest parameter. | |
let {flora, …rest} = ifebhor; |
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 brands = ["Nike", "Gucci", "Adidas"]; | |
console.log(brands[0], brands[1], "and", brands[2], "are in vogue now."); | |
//Output: Nike Gucci and Adidas are in vogue now. |
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 brands = ["Nike", "Gucci", "Adidas"]; | |
let [nike, gucci, adidas] = brands; | |
console.log(nike, gucci, “and”, adidas, “are in vogue now.”); | |
//Output: Nike Gucci and Adidas are in vogue now. |
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 nike, gucci, adidas; | |
let brands = ["Nike", "Gucci", "Adidas"]; | |
[nike, gucci, adidas] = brands; | |
console.log(nike, gucci, “and”, adidas, “are in vogue now.”); |
OlderNewer