Archive for May, 2009

Nifty Little Javascript Array Trick

This may well be common knowledge, but to me I’ve found this little trick immensely useful.

Because Javascript automatically resizes arrays when you add a new item, this nifty little syntax works great for building a new array or adding items on the end:

1: var ar = []; 2: for(var i = 0; i < 50; ;++) { 3: ar[ar.length] = "Some value " + i; 4: }

Obviously the push() and pop() methods work well too, but I find the above syntax slightly more readable since I don’t typically expect an array to have methods like push() and pop().

Continue Reading 2009/05/18 at 23:08 1 comment


My Most Recent Updates

  • Doing a bit of well overdue digital housekeeping. Deleting resource groups and app services left and right! 1 week ago
  • Just finished migrating all my CodePlex projects to GitHub. Bitter sweet, my first OSS contributions were on CodePlex, but its for the best. 1 week ago
  • RT @arstechnica: "These idiots run directly up to your armed-to-the-teeth hero and attack one-at-a-time—like a bad Chuck Norris film" https… 1 week ago
  • VSTS has got some nice stuff going on with Build and Release management. Makes deployments as easy as pie. 1 week ago
  • Suffering from lots of self inflicted minor obstacles, on something I know how to do a different way starting to annoy me. 1 week ago
  • @DrPizza They could at least smooth out the animation on those cogs. Two frames seems awfully low, even for a system update screen. 1 month ago
  • RT @Jimminy: *golf claps* to @apple for focusing all their efforts on making design and usability worse across both hardware and software f… 6 months ago
  • RT @AdamJosephCook: @trevorghess @natebross Indeed. I do not understand why @Meetup is not more prompt about this. The events are clearly j… 6 months ago
  • @trevorghess any word on the coup for the azure meetup group? 7 months ago
  • feedback-hub:?contextid=67&feedbackid=81903edf-4b95-406b-b263-58464bc30744&form=1&src=1 https://t.co/lnRSeFZzI4 10 months ago