Skip to content

Instantly share code, notes, and snippets.

@atleastimtrying
Created March 27, 2013 10:25
Show Gist options
  • Save atleastimtrying/5253234 to your computer and use it in GitHub Desktop.
Save atleastimtrying/5253234 to your computer and use it in GitHub Desktop.
Notes from a chat about js and coffeescript
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
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