JavaScript Basics: Shortcuts to make your life easier

I have to say that at one point, I truly thought that JavaScript was using some type of “black magic”. Things such as closures really threw me for a loop and I was fortunate to have some good folks to walk me through some of the tougher concepts. Not everyone is as lucky and thankfully, we have developers like Christian Heilmann who continue to put out great postings that cover a broad range of topics and experience levels.

In his latest posting, Christian outlines certain JavaScript shortcut notations which make understanding specific JS techniques a whole lot easier. For example, when dealing with objects, there's the involved way of defining objects:

var links = new Object();
links['Cute Overload'] = '';
links['I can has cheeseburger'] = '';
links['Pencils at dawn'] = '';
links['Hobotopia'] = '';

and then there's the easier way using object literals:

var links = {
'Cute Overload' : '',
'I can has cheeseburger' : '',
'Pencils at dawn' : '',
'Hobotopia' : '' // < -- again, no comma! }

Christian provides plenty of great examples that should substantially help new JavaScript developers.