I have an object (an "associate array" so to say - also known as a plain JavaScript object):
obj = {}
obj["Foo"] = "Bar"
obj["bar"] = "Foo"
I want to iterate over obj
using CoffeeScript as follows:
# CS
for elem in obj
bu the CS code above compiles to JS:
// JS
for (i = 0, len = obj.length; i < len; i++)
which isn't appropriate in this case.
The JavaScript way would be for(var key in obj)
but now I'm wondering: how can I do this in CoffeeScript?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…