# destructure (desctucture Array)
there are 2 type of destructure
# 1- desctucture Array
const fruits = ["Apple", "Banana", "Mango"];
console.log('========old way========')
// old
const fruitOld1 = fruits[0];
const fruitOld2 = fruits[1];
const fruitOld3 = fruits[2];
console.log(fruitOld2);
// simple extract
console.log('=======New Way======')
const [fruit1, fruit2, fruit3] = ["Apple", "Banana", "Mango"]; //fruits;
console.log(fruit3)
// first Value and rest another array;
console.log('===first Value and rest another ======')
const [apple, ...other] = fruits;
console.log(apple);
console.log(other);
Note:---we find first fruit from this method but we can't find 2 or 3 fruit so we use object mode method for third and fourth and so on..
// new object mode
const fruits = ["Apple", "Banana", "Mango", "orange"];
const { 2: thirdFruit } = fruits;
console.log(thirdFruit);
https://jsbin.com/losazavose/1/edit?js,console
