反射机制:是指程序在运行时能够获取自身的信息
eg:一个对象在运行时,知道自己的属性和方法
var obj={
name:"zhangkaibo",
age = 25,
talk:function(){alert("my name is zhangkaibo")}
}
var obj1 = function(){
this.name:"zhangkaibo";
var age = 25;
this.talk=function(){alert("my name is zhangkaibo")}
}
function Reflector(obj){
for(var p in obj){
if(typeof(obj[p]) == "function"){
obj[p]();
}else{
alert[p]
}
}
}