Skip to content

Instantly share code, notes, and snippets.

1 is 1
# true
1 is "1"
# false
bundle exec guard
# Guardfile
group 'frontend' do
guard 'coffeescript', :output => 'public/javascripts/compiled' do
watch(%r{^app/coffeescripts/.+\.coffee$})
end
end
# Gemfile:
group :development do
gem 'guard'
gem 'guard-coffeescript'
end
window.Animal = class Animal
window.Dog = class Dog extends Animal
# convention pour une constante mais utilise var
STATES = ["sleeping", "eating"]
constructor: ->
# appelle le constructeur d'Animal
super
registerEvents = (node) ->
node.bind "click", (event) =>
# this est bindé sur le this avant l'appel et non sur l'event
setAttribute = (@attribute) ->
setAttribute = (attribute) -> @attribute = attribute
person = { firstname: "Martin", lastname: "Catty" }
person.introduce = -> console.log "Bonjour, je suis #{@firstname} #{@lastname}."
person.introduce()
# Bonjour, je suis Martin Catty.
window.App = class App