Expected id, string or number

I have an object like this:

var defaults = {
        id: 'ActionSlider',
        element: '',
        closeBtnWidth: 55,
        panelWidth: 320,
        class: '',
        css: {},
        create: function() {},
    },

      

and when I run my page in IE8 standards it gives me the following error:

SCRIPT1028: expected ID, string or number

and points to the line: class: '',

Can someone tell me why I can't use this for IE? is it a reserved word or something else?

+3


source to share


4 answers


You need to add quotation marks around class

which is a reserved word. Also note that you must remove the last comma:



var defaults = {
        id: 'ActionSlider',
        element: '',
        closeBtnWidth: 55,
        panelWidth: 320,
        "class": '',
        css: {},
        create: function() {}
    }

      

+6


source


Yep, class

is a reserved word. MDN



+1


source


class

reserved words in javascript

0


source


Typically a class refers to a class attribute of any object such as <div >

, <input >

etc., which shows the display class as<div class="someclass">

0


source







All Articles