Javascript自定义对象 - IE中的预期标识符

Bob*_*Bob 2 javascript internet-explorer custom-object

我是新手在JavaScript中创建自定义对象,所以它可以很简单.

我有这些对象:

        function jsonObj(_id,_title,_class,_icon)
        {
            this.attr = new jsonAttrObj(_id,_title,_class);
            this.data = new jsonDataObj(_title,_icon);
            this.children = new Array();
        };

        function jsonAttrObj(_id, _title, _class)
        {
            this.id = _id;
            this.title = _title;
            this.class = _class;
        };

        function jsonDataObj(_title, _icon)
        {
            this.title = _title;
            this.icon = _icon;
        };
Run Code Online (Sandbox Code Playgroud)

我把它称为var jsonObject = new jsonObj(id,title,class,icon);所有字符串变量.

它们在Chrome和Firefox中运行良好,但不适用于IE(8).IE有错误 - 预期标识符.

JAA*_*lde 5

您不能将保留关键字"class"用作任何变量或属性名称.这里有趣的事情 - 这是IE正确的其中几个地方之一,其余的不是.