One of the many ways of creating new objects in JavaScript is through using constructor functions.

Here is one example of that.

We have a simple function conveniently called Person that takes name and age and then returns a new object with name and age if called with the new keyword. But what was the magic here, we run a function and got an object even when the function returns nothing. The magic lies with the power of new. Before that, though, let’s explore a few other phenomena.

#web-development #programming #react #javascript #webdev

How do Constructor Functions Work in JavaScript?
32.45 GEEK