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
iam4x
94.17K
ericdfields
63.02K
Related Tags
#coffeescript
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#