![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
前端
XBB2333
前端学习中,请多多关照;
展开
-
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 · 153 阅读 · 0 评论 -
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 · 239 阅读 · 0 评论 -
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 · 498 阅读 · 0 评论 -
this的三种情况
如果把一个函数当作一个方法来用,那他就等于他的父级对象无论是全局环境中的函数,还是匿名函数里面的this都是 undefined作为构造器,this等于即将生成的那个对象...转载 2018-07-01 13:12:42 · 168 阅读 · 0 评论