Ankh

exports

method
module.exports()

Option name Type Description
Constructor Function

The prototype you wish to instantiate

args Any

The arguments to new up the instance with

return Object

new instance of Constructor

Simulates calling new MyConstructor with dynamic args

module.exports = function dynamicNew(Constructor, args) {
    var result = Object.create(Constructor.prototype)
    if(!result) {
        throw new Error('Could not dynamically new ' + toString.call(Constructor))
    }
    Constructor.apply(result,args || [])
    return result
}