function Person(name, age, job) {
    this.name = name;
    this.age = age;
    this.job = job;
    this.sayName = function() {
        alert(this.name);
    };
}

var person1 = new Person("Mary", 29, "Software Engineer");
var person2 = new Person("Mike", 29, "Software Engineer");

JS创建对象之构造函数模式

相关文章:

  • 2022-12-23
  • 2021-10-23
  • 2022-02-07
  • 2021-11-04
  • 2022-02-28
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
猜你喜欢
  • 2022-12-23
  • 2021-12-07
  • 2021-08-15
  • 2021-09-28
  • 2021-10-23
  • 2022-01-25
  • 2022-12-23
相关资源
相似解决方案