dillon-sellars / BeautyTips

BeautyTips is a jQuery tooltips plugin which uses the canvas drawing element in the HTML5 spec to dynamically draw tooltips (sometimes called "talk bubbles" or "help balloons") associated with a html element on the page.
35 stars 8 forks source link

Don't use (for...in) to iterate over arrays #6

Open andi opened 11 years ago

andi commented 11 years ago

There are several occurrences of a for-in loop to iterate over Arrays because it iterates over all property Names of the Array. See http://stackoverflow.com/questions/242841/javascript-for-in-vs-for for more details. I'm using Ember.js which extends the Array with several properties and functions, so beautytips don't work anymore.

To fix this, Arrays need to be iterated using

for (var i = 0; i < myArray.length; i++)

or

for(var name in obj)
{
    if (obj.hasOwnProperty(name))
    {
    }
}