Reputation: 215
I want to do something like this.
var abc = require('./index')
var x = "someModule";
abc.x.someFunction();
So basically I want to do something like this:
abc.someModule.someFunction();
How do I achieve this?
Upvotes: 0
Views: 555
Reputation: 10148
Use bracket notation
Something like
var x = "someModule";
abc[x].someFunction();
Upvotes: 1
Reputation: 1915
This should work:
var abc = require('./index')
var x = "someModule";
abc.[x].someFunction();
Upvotes: 0