When working with object literals in JavaScript, I find myself frequently generating syntax issues around the last label / value pair since it does not require the trailing comma. I insert a new value and inevitably forget the separating comma.
.draggable({
containment: "parent",
opacity: 0.50 // <- missing comma
revert: true // new pair
});
So for the sake of my sanity, would it be reasonable to always have a dummy pair at the end? This seems to work and now all inserted pairs get a trailing comma. Are there other conventions out there? Is the double quote brilliant or idiotic? Feedback please! Thanks.
.draggable({
containment: "parent",
opacity: 0.50,
"": null // dummy pair
});
No.
This is simply silly.
What you want instead is using code quality tools like jslint and jshint. If you hook these into your pre-commit on your version control or your text editor safe mechanism then you’ll never miss these errors.
Alternatively you can try writing your code isaacs style