开发者

JavaScript: JSLint throws "Read Only

开发者 https://www.devze.com 2023-01-15 20:19 出处:网络
My code: n开发者_如何转开发ote: the Slider Object is declared but omitted in the snippet below for better readability

My code:

n开发者_如何转开发ote: 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?


Try this:

 /*global arrayContainer:true, SliderInstance:true, DomObjects:true, document, Slider*/

Informs JSLint that these globals are assigned intentionally.


use

/*global arrayContainer:true, SliderInstance:true, DomObjects:true */

see doco under 'Global Variables' - the 'true' says that this file can assign to those variables.

0

精彩评论

暂无评论...
验证码 换一张
取 消