I'm refactoring a javascript codebase and am implementing, but I'm new to node. I might run into some code like this:
foo.js
var foo = {};
foo.bar = function(baz) {
$('body').append(baz)
}
which i would then refactor into the following:
foo.js
var $ = require('jquery')(window);
var foo = {};
foo.bar = require('./bar');
bar.js
module.exports = bar = function(baz) {
$('body').append(baz);
}
What's the correct way to pass the jQuery object from foo.js to bar.js without interfering with the baz parameter when foo.bar(baz) is called?