Skip to content

Pass through arguments to Instantiate the given class #24

@yorkie

Description

@yorkie

Here is the demo function:

// utils for pass a class constructor and arguments, and return the
// instance of the given class.
function passthroughModule(initializer, args) {
  return new (Function.prototype.bind.apply(initializer, [null].concat(args)));
}

Then we would use this function:

class Foo { ... }
passthroughModule(Foo, args);

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions