3 ms·
Watch out for for (var prop in obj) {} It may iterate over attributes defined in the objects prototype. The right way to iterate over an object is fo
by VMG 14y ago
Watch out for
for (var prop in obj) {}
It may iterate over attributes defined in the objects prototype. The right way to iterate over an object is
for(var prop in obj) {
if(obj.hasOwnProperty(prop))
doSomethingWith(obj[prop]);
}
(see http://stackoverflow.com/a/588276 http://stackoverflow.com/a/588276)
- drgath 14y agoWhile true, 'data' should always just be an object-literal. If template() is ever passed an instance of an object, there's something else seriously wrong elsewhere in your script.