25

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?

4

2 に答える 2

48

これを試して:

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

これらのグローバルが意図的に割り当てられていることをJSLintに通知します。

于 2010-09-13T23:09:07.630 に答える
6

使用する

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

「グローバル変数」の下のdocoを参照してください-「true」は、このファイルがこれらの変数に割り当てることができることを示します。

于 2010-09-13T23:11:51.297 に答える