练习1:结果:0 5 0 / 0 undefined 0
var a=5;
function test(){
a=0;
console.log(a)
console.log(this.a)
var a; //去掉,test()结果0 0 0
console.log(a)
}
test(); //0 5 0
new test(); //对象,this.a没有赋值 0 undefined 0
练习2:
练习3:判断是不是数组方法
var obj = [];
console.log(obj instanceof Array);
console.log(obj.constructor==Array)
console.log(Object.getPrototypeOf(obj) == Array.prototype);
console.log(Array.prototype.isPrototypeOf(obj));
console.log(Object.prototype.toString.call(obj) == '[object Array]');
console.log(Array.isArray(obj));
练习4:var
var a=5;
b=5;
delete b;
console.log(a) //被var的变量,不会被删除,结果:5
console.log(b) //没var的可以删除,结果:b is not defined
练习5: 对象赋值地址,改原内容,