Iterate over coffeescript object

How to iterate keys in an object to display the key and the values ​​associated with it? Let's say the hash looks like this:

hash = a: 'b' c: 'd' e: 'f' 
+8
coffeescript
source share
2 answers

Try the following:

 for k, v of hash console.log('%s %s', k, v) 
+5
source share
 for key, value of hash console.log "#{key} = #{value}" 
+17
source share

All Articles