Skip to content

Instantly share code, notes, and snippets.

@michelle
Created March 2, 2013 05:12
Show Gist options
  • Save michelle/5069792 to your computer and use it in GitHub Desktop.
Save michelle/5069792 to your computer and use it in GitHub Desktop.
More CoffeeScript oddities.
window.Michelle =
username: 'michellebu'
Hobbies:
daytime: 'biking'
evening: 'walks'
Friends: {}
class Michelle.Friends.Michelle
username: 'othermichelle'
morningCompatible: ->
# Will error because Hobbies is undefined.
Michelle.Hobbies.daytime is 'running'
eveningCompatible: ->
# Will error because Hobbies is undefined.
Michelle.Hobbies.evening is 'drinking'
# compiled:
window.Michelle = {
username: 'michellebu',
Hobbies: {
daytime: 'biking',
evening: 'walks'
},
Friends: {}
};
Michelle.Friends.Michelle = (function() {
function Michelle() {}
Michelle.prototype.username = 'othermichelle';
Michelle.prototype.morningCompatible = function() {
return Michelle.Hobbies.daytime === 'running';
};
Michelle.prototype.eveningCompatible = function() {
return Michelle.Hobbies.evening === 'drinking';
};
return Michelle;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment