1

I'm trying out the new destructuring feature of ES6, but having some trouble either understanding it, or getting it to work.

var test = {
    testme: "asd",
    funcA: function() {
       console.log("A");
   }
};
var [ testme, funcA ] = test;
console.log(testme);
console.log(funcA);

I expected to see in the console "asd" and function() { ... } but I get undefined for both.

Using Firefox 28.0

CodingIntrigue
  • 75,930
  • 30
  • 170
  • 176

1 Answers1

2

If you destructure an object you have to use the object's structure:

var {testme, funcA} = test;
elclanrs
  • 92,861
  • 21
  • 134
  • 171