Just a running list of helpful JS nuggets I want to keep track of... some may or may not be a surprise to you.

  1. When checking if a property or method exists in a given object, you can simply write an if statement like so:

    if ('name' in person) {
      // do something
    }
    
  2. HTML5 Image constructor

    var image = new Image()
    image.onload = function () {
      // do something
    }
    image.src = ''; // triggers image.onload event
    
Tags: