var object = {}; // Global Object
(function() {
var theArg, google, yahoo;
object.google = function(arg) {
theArg = arg;
alert(theArg);
}
object.yahoo = function() {
alert(theArg);
}
module.exports = yahoo;
})();
// This will set initial value of
google("Hello World");
Can i call something like this module.exports = yahoo; and calling the yahoo function else where.
You can use:
test.js
var object = {}; // Global Object
alert = console.log;
(function() {
var theArg, google, yahoo;
object.google = function(arg) {
theArg = arg;
alert(theArg);
}
object.yahoo = function() {
alert(theArg);
}
module.exports.yahoo = object.yahoo;
})();
// This will set initial value of
object.google("Hello World");
main.js
require('./test.js').yahoo();