user2042215
user2042215

Reputation: 45

Expected identifier, string or number

I have an object like;

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

and when i run my page in IE8 standards its giving me the following error;

SCRIPT1028: Expected identifier, string or number

and points to the line : class:' ',

can anyone please tell me why i cant use this for IE? is it a reserved word or something?

Upvotes: 3

Views: 2580

Answers (4)

Javier Brooklyn
Javier Brooklyn

Reputation: 634

Usually class refers to the class attribute of any object like <div >, <input > etc. which shows displays class as <div class="someclass">

Upvotes: 0

Iswanto San
Iswanto San

Reputation: 18569

class is reserved words in javascript

Upvotes: 0

KARASZI Istv&#225;n
KARASZI Istv&#225;n

Reputation: 31467

You need to add quotes round the class which is a reserved word. Please also note, that you should remove the last comma:

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

Upvotes: 6

phenomnomnominal
phenomnomnominal

Reputation: 5515

Yep, class is a reserved word. MDN

Upvotes: 1

Related Questions