The Javascript in
operator does what Hash#has_key?
does in Ruby: Return whether an object has a property.
However, Coffeescript has its own in
operator that checks for array inclusion. To check whether an object has a property, use of
:
Javascript
'name' in {name: 'Horst'} # => true
Coffeescript
# wrong
'name' in {name: 'Horst'} # => false
# correct
'name' of {name: 'Horst'} # => true
1 in [1,2,3] # => true
True story.
Posted by Dominik Schöler to makandra dev (2015-02-18 13:03)