簡體   English   中英

解構返回的未定義變量

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM