jslint 抱怨 __proto__ 是保留字
这是有问题的代码:
hasOwnProperty: function (obj, prop) {
var hasOwn = Object.prototype.hasOwnProperty,
proto;
if (hasOwn) {
return hasOwn.call(obj, prop);
} else {
proto = obj.__proto__ || obj.constructor.prototype;
return (prop in obj) && (!(prop in proto) || proto[prop] !== obj[prop]);
}
}
jslint 失败,同时吐出此错误:
Error:
Problem at line 653 character 29: Reserved name '__proto__'.
proto = obj.__proto__ || obj.constructor.prototype;
任何想法/解决方案?
Here is the code in question:
hasOwnProperty: function (obj, prop) {
var hasOwn = Object.prototype.hasOwnProperty,
proto;
if (hasOwn) {
return hasOwn.call(obj, prop);
} else {
proto = obj.__proto__ || obj.constructor.prototype;
return (prop in obj) && (!(prop in proto) || proto[prop] !== obj[prop]);
}
}
jslint fails while spitting out this error:
Error:
Problem at line 653 character 29: Reserved name '__proto__'.
proto = obj.__proto__ || obj.constructor.prototype;
Any ideas/solutions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎让 jsLint 保持安静:
This seems to keep jsLint quiet: