构造函数
构造函数习惯上 首字母 大写
构造函数 和 普通函数的区别:普通函数直接调用,构造函数 new 调用
1、创建的对象({})会赋值成 构造函数 名字的 类 Person {}
2、构造函数 就是 创建一个新对象
3、函数内部 通过 this 访问 新对象
4、不需要 retrun,构造函数 会自动返回 新对象
function Person(name, age, funcs) {
this.name = name;
this.age = age;
this.funcs = funcs
}
var per = new Person("测试", 15, function () {
console.log(this.age)
});
console.log(per)
per.funcs()