JS constructor

Using objects in JavaScript is very simple. Use the new operator to execute the Object function to build a most basic object.

var obj = new Object();

We call the function called by new a constructor. The difference between a constructor and an ordinary function is whether Using new to call, their return value will be different

Constructor is a function specially used to generate objects. It provides templates as the basic structure of objects. A constructor can generate multiple objects, all of which have the same structure. The

so-called constructor is to generate a new object through this function. At this time, this refers to the new object

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327059632&siteId=291194637