0
我有一些代码,构造一个对象:的javascript:严格的模式和对象
function gridObjConst(id, itemName, itemPrice, itemListPrice, width, height, imgName) {
this.id = id;
this.itemName = itemName;
this.itemPrice = itemPrice;
this.itemListPrice = itemListPrice;
this.width = width;
this.height = height;
this.imgName = imgName;
return this;
}
我用了W3Schools的页面作为指导:http://www.w3schools.com/js/js_objects.asp
这一切都工作得很好。然后我在代码的顶部添加了“严格使用”,并且此功能打破了。 Firebug报告:这是不明确的 - this.id = id
我该如何解决这个问题?
你使用'new gridObjConst(...)'还是'gridObjConst(...)'? –
另外:您可能想要寻找[比w3schools更可靠的来源](http://w3fools.com/)。 –