My Profile Photo

rubycoloredglasses


I'm Jason, a web applications developer in the San Francisco Bay area.


Using 'for in' in Javascript

Today our lead front-end developer pointed out to me that when using a ‘for in’ loop in Javascript that you want to make sure to use hasOwnProperty() on the element to make sure it belongs to the object, and not properties that were inherited through the prototype chain.

More information is available on this page describing common Javascript code mistakes caught by JSLint.