glejeune/node-graphviz — pull request #17 by dariusk (2014-03-26 20:22:40+00:00)
Title: Fixing `for in` loops

This library uses several `for in` loops -- but `for in` traverses the prototype chain,
which means that the lexer throws an error if anything is attached to, for example,
`Array.prototype`. (I have an `Array.prototype.pick` function that returns a random
element from an array, which broke this library.)

By adding `if (collection.hasOwnProperty(i))` to each `for in` loop, we avoid
looping over things added to the prototype, looping only over properties that are
'really' in the collection.

For more info on `hasOwnProperty` as a `for in` filter, see:
http://bonsaiden.github.io/JavaScript-Garden/#object.forinloop