Languages
[Edit]
EN

JavaScript - how to use '.call(...)' method with (or instead) 'new' operator

5 points
Created by:
Reilly-Collier
860

In this article we would like to show how to create object with MyClass.call(...) method instead of new operator in JavaScript.

Simple solution:

Note: read this article to see MyClass.apply(...) method examples.

Check below alternative solutions:

Alternative solutions

Edit

There are few different ways how to achieve same effect, what was presenbted in this section.

new operator with .bind.call(...) methods example

Edit

new operator, .bind.call(...) methods with Function class example

Edit

Alternative titles

  1. JavaScript - create object with call() method of class
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join