-5

Here it is:

var obj = {
    'city': 'ny',
}

I write a comma in the end after ny

but this could run in Chrome and Firefox, but not in IE6/7

So does this kind of syntax is right or wrong or recommended?

hh54188
  • 14,887
  • 32
  • 113
  • 184

1 Answers1

0

there should be not comma,if you have only one key and value.

If you are separating the Key & Value Pairs with comma then it is called as Object Literals.
var obj = {
    'city': 'ny'
}
Developer
  • 1,409
  • 2
  • 23
  • 46