Created
July 24, 2012 14:16
-
-
Save jccrosby/3170149 to your computer and use it in GitHub Desktop.
RealEyes Coding Standards
This file contains 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
function Animal( name, health ) { | |
this.name = name; | |
this.health = health; | |
} | |
Animal.prototype.eat = function( value ) { | |
this.health += value; | |
}; | |
function Snake( name, health ) { | |
Animal.call( this, name, health ); | |
this.aggression = 50; | |
} | |
Snake.prototype = new Animal(); | |
Snake.prototype.constructor = Snake; | |
Snake.prototype.eat = function( value ) { | |
Animal.prototype.eat.call( this, value ); | |
this.aggression -= value; | |
}; | |
var ralph = new Animal( 'Ralph', 50 ); | |
ralph.eat( 50 ); | |
var sid = new Snake( 'Sid', 100 ); | |
sid.eat( 20 ); |
This file contains 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
function distanceTo( startX, startY, endX, endY ) { | |
var dx = startX - endX; | |
var dy = startY - endY; | |
return Math.sqrt( dx * dx + dy * dy ); | |
} |
This file contains 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
var moduleExample = ( function() { | |
var privateVariable = 'Module'; | |
return { | |
publicProperty: 'moduleExample.publicProperty', | |
publicMethod: function() { | |
return privateVariable; | |
}; | |
}; | |
}() ); |
This file contains 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
var someVar = 0; | |
if( typeof someVar === 'undefined' ) { | |
someVar = 0; | |
} else { | |
for( var i = 0; i < 10; i += 2 ) { | |
someVar += i; | |
} | |
} | |
switch( someVar ) { | |
case 0: | |
console.log( 'started as undefined' ); | |
break; | |
case 20: | |
console.log( 'started as 0' ); | |
break; | |
default: | |
console.log( 'neither' ); | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment