This week’s tip is actually a link to a blog entry about JavaScript notations and comes from Chris Heilmann’s ‘Wait till I come!‘ site.
If you’re still learning JavaScript, or perhaps you are self-taught, you may find this article useful as Chris shows us some of the more useful JavaScript shortcut notations available.

JavaScript Notations

There’s the Array Shortcut Notation, which allows us to set arrays that are easier to maintain and involve less code repetition while still retaining a relative numeric position assignment:

var links = [
  'http://www.weeklywebdev.com',
  'http://www.wait-till-i.com/',
  'http://www.andismith.com'
];

There’s Literal Notation, for defining objects:

var website = {
  name : 'Weekly Web Dev',
  url : 'http://www.weeklywebdev.com',
  location : 'London, England'
}

And, finally, there’s ternary notation:

var popular = (sitehits > 1000) ? true : false;

You can read the full entry here.

Tags:

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>