js构造函数

1.实质:一个普通函数。创建方式和普通函数一样。规范:首字母大写

2.对构造函数使用new运算符,就能生成实例,并且this变量会绑定在实例对象上。

 

ex:

function Person(name,age){
  this.name = name
  this.age = age                 
}

let p1 = new Person('syq','18')

 

posted @ 2019-12-04 17:37  white55k  阅读(108)  评论(0编辑  收藏  举报