Destructuring is used to extract the array elements or object properties and store them in variables.
See the example below,
Object destructuring
//Array destructuringconst number = [1, 2, 3];const [num1, , num3] = numberconsole.log(num1, num3)Output:1 3
Array destructuring
//Object destructuringconst myFriends = { friend1:'Nivedh', friend2:'Vibin', friend3:'Joel'}const {friend2, friend1} = myFriendsconsole.log(friend1, friend2)Output:Nivedh Vibin
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse