CoffeeScript
Last updated
Last updated
more coffeescript tricks: https://gist.github.com/dfurber/993584
loop array: for item in arr
or for item, index in arr
loop object: for prop, value of obj
or for own property, value of object
(use hasOwnProperty())
read this
use => when we need @ to be the object in which method is written; use-> when we need @ to be the object in which method is executed.
print = """
1st line
2nd line
#{supports interpolation}
last line
"""
class Songs
_titles: 0 # instance var, Although it's directly accessible, the leading _ defines it by convention as private property.
get_count: ->
@_titles # access instance var
call_another_method: ->
return @get_count() # call another instance method
Router.go 'home', ->
this.render 'home'
,
name: 'h'
old: 'b'
coffeescript reverse for loop: for i in [arr.length-1..0] by -1
iterations in coffeescript