Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does jslint shout at me?

Tags:

jslint

My code is the following (also available at jsfiddle):

$button = $('<button />', {
    text: 'my button',
    class: 'button'
});

The jslint error message is:

Problem at line 3 character 5: Expected an identifier and instead saw 'class' (a reserved word).
class: 'button'
like image 661
Randomblue Avatar asked Feb 23 '23 11:02

Randomblue


1 Answers

Class is a reserved word for Javascript 2.0, thus you should not use it as a key in an object without putting it between quotes to mark it as a string.

like image 156
Luiz Sócrate Avatar answered Apr 05 '23 23:04

Luiz Sócrate