nazerke
11/3/2016 - 8:33 AM

destructuring objects

destructuring objects

var foo={
  bar: 1,
  baz: 3,
  bla: 4
  };
  
  var {a1,b2} = foo;// ==  var a1 = foo.bar; var b2 = foo.baz;
  
  
//destruction of objects
var foo = 2;

var obj = {
  bar: 1,
  foo//same as foo:2
  };
  
  
  //passing an object by destructuring
  var name = "Will";
  var age = 34;
  
  some.method({name,age});
  
  //generating keys
  
  var object = {
    ["name"+name]:"some value"; //nameWill: "some value"
  }