@@MohammedAli-p7e9d yes, even when you fetch data from API and get json object you will need this , a lot more cases as well in React , actually you have to learn this topic and dive more in it
when object destructuring the new variables can have a different name than the object keys, for example: const {firstName: personName}; (firstName - object key, personName - new variable)
hey these are actually pretty useful tutorials, they touch more advanced topics than the other videos. are these old? or are they new videos? Thanks for everything bro ❤
there is a complete java script 8 Hours , and these series are new. Bro uses different way of doing things in this series , but both are great . and I hope he Dive into Dom more deeper , cause js is the language of controlling DOM at least this is the way I see it : you got to be crazy to use this language for writing apps . I don't know maybe libraries change my mind around this . but in python from the get go you are armed with any tool you need to do what ever you want.
can we use this or rest operator to deliver different amount of arguments like in python when we use (*args , **kwargs) ? destructuring is like unpacking , but is there such a feature in JS I'm really having a hard time with the language coming from python , I wonder if it was better to learn Django
// destructuring = extract values from arrays and objects,
// then assign them to variables in a convenient way
// [] = to perform array destructuring
// {} = to perform object destructuring
// ---------- EXAMPLE 1 ----------
// SWAP THE VALUE OF TWO VARIABLES
let a = 1;
let b = 2;
[a, b] = [b, a];
console.log(a);
console.log(b);
// ---------- EXAMPLE 2 ----------
// SWAP 2 ELEMENTS IN AN ARRAY
const colors = ['red', 'green', 'blue', 'black', 'white'];
[colors[0], colors[4]] = [colors[4], colors[0]]
console.log(colors);
// ---------- EXAMPLE 3 ----------
// ASSIGN ARRAY ELEMENTS TO VARIABLES
const [firstColor, secondColor, thirdColor, ...extraColors] = colors;
console.log(firstColor);
console.log(secondColor);
console.log(thirdColor);
console.log(extraColors);
// ---------- EXAMPLE 4 ----------
// EXTRACT VALUES FROM OBJECTS
const person1 = {
firstName: 'Spongebob',
lastName: 'Squarepants',
age: 30,
job: "Fry cook",
};
const person2 = {
firstName: 'Patrick',
lastName: 'Star',
age: 34
};
const {firstName, lastName, age, job="Unemployed"} = person2;
console.log(firstName);
console.log(lastName);
console.log(age);
console.log(job);
// ---------- EXAMPLE 5 ----------
// DESTRUCTURING IN FUNCTION PARAMETERS
function displayPerson({ firstName, lastName, age, job="Unemployed" }) {
console.log(`name: ${firstName} ${lastName}`);
console.log(`age: ${age}`);
console.log(`job: ${job}`);
}
displayPerson(person1);
displayPerson(person2);
Extraordinary well explained and examples were very good. Thank you so much!
Great job Bro Code! I became addicted to your tutorials. I admire the amount of work you invest in developing these learning materials.
Thanks for showing this with arrays first, makes it easier to understand
Now this is solid explanation, I was starting it today and had some unclear parts on the function part... But u made it clear for me thanks bro
You teach really well! Thank you so ,much for this tutorial. Helped a lot!
Who else is here after starting useState hook in react js without knowing JavaScript in depth like me ? 😂
Is this topic important in react js?
@@MohammedAli-p7e9d yes
@@MohammedAli-p7e9d Yes
@@MohammedAli-p7e9d To understand useState() you need to know how destructuring works.
@@MohammedAli-p7e9d yes, even when you fetch data from API and get json object you will need this , a lot more cases as well in React , actually you have to learn this topic and dive more in it
Fairly convincing human voice on this AI.
its really ai??
Wow! Great video. 😄 Very explanatory, finally understood this topic
Thanks Bro for your simple but great explanation!
This is my seal. I have watched the entire video, understood it, and I can explain it in my own words, thus I have gained knowledge. This is my seal.
when object destructuring the new variables can have a different name than the object keys, for example: const {firstName: personName}; (firstName - object key, personName - new variable)
Patric is coding ever since dropping out of spongebob show, its expected of him to pop up again somewhere in apple
really helpful video thanks😃
Thanks you so much bro, you teach so detail and i can understand now
Really awesome, bro thanks a bunch!
Great video, thanks!
very great tutorial
What about destructuring object inside an object? Hope you can make a video about that soon!
hey these are actually pretty useful tutorials, they touch more advanced topics than the other videos. are these old? or are they new videos? Thanks for everything bro ❤
there is a complete java script 8 Hours , and these series are new. Bro uses different way of doing things in this series , but both are great . and I hope he Dive into Dom more deeper , cause js is the language of controlling DOM at least this is the way I see it : you got to be crazy to use this language for writing apps . I don't know maybe libraries change my mind around this . but in python from the get go you are armed with any tool you need to do what ever you want.
goat
The patrick in the object destruction example is me 😢😢
Smooth
can we use this or rest operator to deliver different amount of arguments like in python when we use (*args , **kwargs) ? destructuring is like unpacking , but is there such a feature in JS
I'm really having a hard time with the language coming from python , I wonder if it was better to learn Django
thank you bro
😘thank you
What about "this" or static in obj ?
W
Is that your normal voice?
I think he deliberately makes his voice a little bit deeper to go with his theme of a "bro". That has to strain his throat lol
@@lobomalsano its his normal voice
37😜