Created
August 5, 2010 22:54
-
-
Save eggie5/510545 to your computer and use it in GitHub Desktop.
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 sys=require('sys'); | |
var mamlib=require('./mammal'); | |
console.log(sys.inspect(mamlib)); | |
=> {} | |
WHY??? |
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 Mammal(name){ | |
this.name=name; | |
this.offspring=[]; | |
} | |
Mammal.prototype.haveABaby=function(){ | |
var newBaby=new Mammal("Baby "+this.name); | |
this.offspring.push(newBaby); | |
return newBaby; | |
} | |
Mammal.prototype.toString=function(){ | |
return '[Mammal "'+this.name+'"]'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment