As shown below:
var person = new Object();
person.name = "Nicholas";
person.age = "29"
person.job = "Software Engineer";
person.sayName = function () {
alert(this.name);
};
person.sayName(); The above example creates an object named person and adds three attributes to it (name, age and job) and a method (sayName()). Among them, the sayName() method is used to display the value of this.name(). Early JavaScript developers often used this pattern to create new objects. But this method has an obvious disadvantage: using the same interface to create many objects will produce a lot of duplicate code. To solve this problem, people started using a variant of the factory pattern.