Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 类型错误:';MyClass.MyFunction不是一个函数';ES6/Node 4中的错误消息_Javascript_Node.js_Ecmascript 6_Immutable.js - Fatal编程技术网

Javascript 类型错误:';MyClass.MyFunction不是一个函数';ES6/Node 4中的错误消息

Javascript 类型错误:';MyClass.MyFunction不是一个函数';ES6/Node 4中的错误消息,javascript,node.js,ecmascript-6,immutable.js,Javascript,Node.js,Ecmascript 6,Immutable.js,我面临一个bug,我可以在node.js 4.0应用程序中使用以下代码复制该bug: "use strict"; var Immutable = require("immutable"); class AspectType { constructor(htmlLabel) { this.hhtmlLabel = htmlLabel; } htmlLabel() { return this.hhtmlLabel; } } var AspectTypes = Immutable

我面临一个bug,我可以在node.js 4.0应用程序中使用以下代码复制该bug:

"use strict";

var Immutable = require("immutable");

class AspectType {
    constructor(htmlLabel) { this.hhtmlLabel = htmlLabel; }
    htmlLabel() { return this.hhtmlLabel; }
}

var AspectTypes = Immutable.OrderedMap()
    .set("C",new AspectType("xxx"))
    .set("D",new AspectType("yyy"))
    .set("E",new AspectType("zzz"));


for (var retr in AspectTypes.values()) {
    console.log(retr.htmlLabel());
}
我收到以下错误消息,为什么

TypeError: retr.htmlLabel is not a function
    at Object.<anonymous> (...\testt.js:17:22)
TypeError:retr.htmlabel不是函数
反对。(…\testt.js:17:22)
Pfff

for (var retr of AspectTypes.values()) {
不是


为什么要使函数名与在构造函数中传递的字符串参数相同?这太令人困惑了!你的代码在babel中确实有效。嗯。我没有用巴贝尔,也不想用它…@Willian你注意到了的
中的
之间的区别吗,这解释了错误的来源?
for (var retr in AspectTypes.values()) {