JavaScript:JSLint 抛出“只读”
我的代码:
注意:为了更好的可读性,在下面的代码片段中声明了滑块对象,但省略了
"use strict";
/*global arrayContainer, SliderInstance, DomObjects */
arrayContainer = new Slider.constructArray();
SliderInstance = Object.beget(Slider);
DomObjects = {
animationContainer: document.getElementById('animationContainer'),
buttonRight: document.getElementById('buttonRight'),
buttonRightDots: document.getElementById('buttonRightDots'),
ieEffectImg: document.getElementById('ie_effectIMG')
};
这就是 JSLint 产生的结果(以及其他两个对象 SliderInstance 和 DomObjects 上的结果)
Error:
Problem at line 3 character 1: Read only.
arrayContainer = new Slider.constructArray();
Problem at line 3 character 1: Stopping. (27% scanned).
如何满足 JSLint 的要求? “只读”是什么意思?意思是?
My code:
note: the Slider Object is declared but omitted in the snippet below for better readability
"use strict";
/*global arrayContainer, SliderInstance, DomObjects */
arrayContainer = new Slider.constructArray();
SliderInstance = Object.beget(Slider);
DomObjects = {
animationContainer: document.getElementById('animationContainer'),
buttonRight: document.getElementById('buttonRight'),
buttonRightDots: document.getElementById('buttonRightDots'),
ieEffectImg: document.getElementById('ie_effectIMG')
};
This is what JSLint produces (and on the other two Objects SliderInstance and DomObjects)
Error:
Problem at line 3 character 1: Read only.
arrayContainer = new Slider.constructArray();
Problem at line 3 character 1: Stopping. (27% scanned).
How do I satisfy JSLint's requirements? What does "Read only." mean?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
通知 JSLint 这些全局变量是有意分配的。
Try this:
Informs JSLint that these globals are assigned intentionally.
使用
参见“全局变量”下的 doco - 'true' 表示该文件可以分配给那些变量。
use
see doco under 'Global Variables' - the 'true' says that this file can assign to those variables.