Skip to content

Instantly share code, notes, and snippets.

View nonseodion's full-sized avatar
💭
BUIDLing

Ifebhor Odion Nonse nonseodion

💭
BUIDLing
View GitHub Profile
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'
// 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",
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 +".");
//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
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;
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
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;
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.
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.
let nike, gucci, adidas;
let brands = ["Nike", "Gucci", "Adidas"];
[nike, gucci, adidas] = brands;
console.log(nike, gucci, “and”, adidas, “are in vogue now.”);