- 博客(4)
- 收藏
- 关注
转载 this的三种情况
如果把一个函数当作一个方法来用,那他就等于他的父级对象无论是全局环境中的函数,还是匿名函数里面的this都是 undefined作为构造器,this等于即将生成的那个对象...
2018-07-01 13:12:42 177
原创 constructor
function User(name, age){ this.name = name; this.age = age;}User.prototype.greet = function(){ console.log('hi,我是' + this.name + '我现在' + this.age + '岁');}var bb = new User('BB',22); var bb = new ...
2018-06-29 16:00:28 509
原创 prototype
function User(name, age){ this.name = name; this.age = age;}User.prototype.greet = function(){ console.log('hi,我是' + this.name + '我现在' + this.age + '岁');}var bb = new User('BB',22);//这里bb已经实例化,User...
2018-06-29 15:50:01 250
原创 function 执行的一些小疑问
function User(name, age){ this.name = 'bb'; this.age = age;}User.prototype.greet = function(){ //prototype在User里面创建了一个名叫 greet 的 function, console.log('hi,我是' + this.name + '我现在' + this.age ...
2018-06-29 15:28:25 161
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人