Created
March 27, 2013 10:25
-
-
Save atleastimtrying/5253234 to your computer and use it in GitHub Desktop.
Notes from a chat about js and coffeescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.alex = {} | |
class window.alex.Wheel | |
constructor: (id)-> | |
console.log id | |
rotate: -> | |
console.log 'turning' | |
class window.alex.Car | |
constructor: -> | |
@wheels = [] | |
@wheels.push(new Wheel(1)) | |
@wheels.push new Wheel 2 | |
@wheels.push new Wheel 3 | |
@wheels.push new Wheel 4 | |
rotate: -> | |
wheel.rotate() for wheel in @wheels unless wheel.id is 1 | |
public : -> | |
console.log 'public' | |
class window.alex.Van extends window.alex.Car | |
constructor: -> | |
$ -> | |
window.car = new alex.Car |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.alex = {}; | |
window.alex.Wheel = function(){ | |
this.rotate = function(){ | |
console.log('turning'); | |
}; | |
}; | |
window.alex.Car = function(){ | |
this.wheels = []; | |
this.wheels.push(new Wheel()); | |
var priv = function(){ | |
console.log('hello world'); | |
}; | |
var public = function(){ | |
console.log('public'); | |
}; | |
var public_two = function(){ | |
priv(); | |
}; | |
return { | |
priv : priv, | |
public: public, | |
public_two: public_two | |
}; | |
}; | |
$(function(){ | |
window.car = new alex.Car(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment