created by Brian LeRoux & Andrew Lunny. sparodically uncurated by David Trejo.

2012 12 28 undefined props on numbers

    function getBounds(node) {
        var n = node || 0;
        return { width: n.width, height: n.height };
    }

If you call getBounds() with null, you'll get back { width: undefined, height: undefined } because in JS, numbers have properties (inherited from Number), and using an undefined property doesn't throw, it just returns undefined. null and undefined are propertyless. Definitely not what I expected in a quick reading of code like this.

@unwiredben

Fork me on GitHub