1//destructuring array
2const alphabet = ['a', 'b', 'c', 'b', 'e'];
3const [a, b] = alphabet;
4console.log(a, b);
5//Expected output: a b
1let [a, b] = [9, 5]
2[b, a] = [a, b]
3console.log(a, b);
4//Expected output: 5,9
1let [greeting = "hi",name = "Sarah"] = ["hello"];
2
3console.log(greeting);//"Hello"
4console.log(name);//"Sarah"
5
1const foo = ['one', 'two', 'three'];
2
3const [red, yellow, green] = foo;
4console.log(red); // "one"
5console.log(yellow); // "two"
6console.log(green); // "three"
7
1const { name, age, job } = { name: 'abrar', age: 24, job: 'web-developer' }
2console.log(name, age, job)