[英]Destructuring returning undefined variables
我正在嘗試ES6的新解構功能,但是在理解它或使其工作時遇到了一些麻煩。
var test = {
testme: "asd",
funcA: function() {
console.log("A");
}
};
var [ testme, funcA ] = test;
console.log(testme);
console.log(funcA);
我希望在控制台中看到"asd"
和function() { ... }
但是兩者都undefined
。
使用Firefox 28.0
如果要分解對象,則必須使用該對象的結構:
var {testme, funcA} = test;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.