Created
May 6, 2012 21:21
-
-
Save Enome/2624513 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
module.exports = { | |
bark: function(){ | |
console.log('woof'); | |
}, | |
speak: function(){ | |
this.bark() | |
} | |
}; |
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
// Test 1 | |
var dog = require('./dog'); | |
dog.speak(); //woof | |
// Test 2 | |
require('./dog').speak(); //woof | |
// Test 3 | |
var speak = require('./dog').speak; | |
speak(); //TypeError: Object #<Object> has no method 'bark' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment