Iterate over object properties
If you need to iterate through an object using Coffeescript, us the of keyword in the loop, ex:
obj = {
stuff: "my stuff"
funk: ()->
alert "My funky function"
more: "more stuff"
}
for x of obj
if typeof(y) is "function"
alert "#{x} is a function!"
else
alert "#{x} is a property"
Written by Peter Peterson
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Coffeescript
Authors
Related Tags
#coffeescript
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#