// 1.直接调用,指向全局
console.log(this);
// 2.在普通函数里调用,指向全局
function fn(){
console.log(this);
}
fn();
3.构造函数普通调用,指向全局(构造函数也是普通函数,可以正常执行)
function Student(){
this.name="zhangsan";
console.log(this);
}
Student();
// 4.构造函数通过new调用创建一个实例对象,指向这个实例对象
var x=0;
function Student(name,x){
this.name=name;
this.x=x;
console.log(this.x);
}
var zhangsan=new Student("zhangsan",1);
var lisi=new Student("lisi",2);
// 5.对象(json创建)里面的方法调用,指向这个对象
var object1={
name:"zhangsan",
show:function(){
console.log(this);
}
}

object1.show();
// 6.对象(通过Object创建)里面的方法调用,指向这个对象
var object2 =new Object();

object2.name="zhangsan";
object2.show=function(){
console.log(this);
}

object2.show();
// 7.对象(通过构造函数创建)里面的方法调用,指向这个对象
function Student(){
this.name="zhangsan"
this.show=function(){
console.log(this);
}
}
var object3=new Student();

object3.show();