For (var key in object) in CoffeeScript?

How can I use for (var key in object) in CoffeeScript? It compiles for ...

for (_i = 0, _len = object.length; _i < _len; _i++) { key = object[_i]; 

... but I just want to iterate though the object.

+70
javascript coffeescript
Jun 21 '11 at 23:29
source share
2 answers

for key of object

Try it in js2coffee

+122
Jun 21 2018-11-11T00:
source share

of keyword:

 for key, value of obj 

or make sure that you check the properties of this object (and not the prototype chain):

 for own key, value of obj 
+64
Jun 21 '11 at 23:32
source share



All Articles