For-each over an array in JavaScript? How can I loop through all the entries in an array using JavaScript? I thought it was something like this: forEach(instance in theArray) Where theArray is my array, but this seems to be incorrect. Answer: L;DR Don't use for-in unless you use it with safeguards or are at least aware of why it might bite you. Your best bets are usually a for-of loop (ES2015+ only), Array#forEach (spec | MDN) (or its relatives some and such) (ES5+ only), a simple old-fashioned for loop, or for-in with safeguards. But there's lots more to explore, read