#Tips

A quick JavaScript formatting tip

IE’s a pain. The particular pain I want to write about is its pickiness about JavaScript object literals. Consider the following JavaScript object:

{ success: function () { ... },
  failure: function () { ... },
}

If you’re used to programming in Perl or Ruby, that trailing comma’s perfectly fine, in fact leaving it there is sometimes considered good practice because it makes it easy to extend the hash, just add a new row and leave another trailing comma.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley , updated

Read more…