I have a NodeJS file which I browserfied using browserify module. I used following command
browserify testFile.js -o bundle.js To make use of this file in browser, I am making use of window object.
Assume below code is generated after browserifying the file.
var Main = function () { this.foo = function () { }, this.temp= function () { }, this.bar= function () { } } to make use I changed it to
window.Main = function () { this.foo = function () { }, this.temp= function () { }, this.bar= function () { } } and then to use of these functions, I used following code:
var obj= new Main (); and then I can say obj.foo(); or obj.bar();
All this is working fine but I wonder if this is the right way to call function from a browserfied file.
Please suggest correct way to make use of browserfied file.