Created
August 31, 2015 16:54
-
-
Save makenova/8a8e9478eba1962428c5 to your computer and use it in GitHub Desktop.
messing with this and node module.exports
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
pt = require('./thisy'); | |
pt.printthis(); |
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 = { | |
printthis: printy, | |
foo: somefoofunc | |
}; | |
function printy (){ | |
// if this file is called from within itself(uncomment line 12), this.foo is undefined | |
this.foo(); | |
// if called from within itself, this is the global node process | |
// if called outside, through an import, this referrs to the export object | |
console.log(this); | |
} | |
// printy(); | |
function somefoofunc (){ | |
console.log('in some foo func'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment