ES6 in Depth
  • Introduction
  • Installation
  • Block Scope
    • Constant
    • Use cases
  • Template String
    • New String Methods
    • Tagged Template Literal
  • New Number Methods
  • Arrow Function
    • Default Parameters
    • Lexical This Scope
    • Where not to use arrow function
  • Object Enhancement
  • New Array Methods
    • For Of
  • Spread Operator
  • Destructuring
    • Array Destructuring
  • Class
  • Symbols
  • New Data Structures
    • Set
    • Map
    • WeakSet
    • WeakMap
    • Iterators
    • Generators
  • Promise
  • Import Export
Powered by GitBook
On this page

Was this helpful?

  1. Destructuring

Array Destructuring

var [name, age] = ["Hemant", 20, "Hyd"];

// using rest operator
var team = ["Hemant", "Vinay", "player1", "player2", "playesr3"]
var [ Boss, Superboss, ...Players ] = team;
console.log(Boss, Superboss, Players); // Hemant Vinay ["player1","player2","playesr3"]

Swap variable

var a =2, b=4;
[a, b] = [b, a];
console.log(a, b); // 4, 2
PreviousDestructuringNextClass

Last updated 4 years ago

Was this helpful?