一:是什么
在JavaScript
中,new
操作符用于创建一个给定构造函数的实例对象
例子
function Person(name, age){ this.name = name; this.age = age; } Person.prototype.sayName = function () { console.log(this.name) } const person1 = new Person('Tom', 20) console.log(person1) // Person {name: "Tom", age: 20} t.sayName() // 'Tom'
标签:具体,age,Person,操作符,Tom,new,name From: https://www.cnblogs.com/chccee/p/17056824.html