得到JavaScript对象中所有的属性和函数的方法

这有点象Java的反射,呵呵~~~

function MyObject(){
	this.color = 'red';
	this.flavor = 'strawberry';
	this.azimuth = '45 degree';
	this.favoriteDog = 'collie';
	this.sayHello = function(){alert('Hello..........!');
	}
}

var myObj = new MyObject();

var debug = "discovering...\n";

for(var i in myObj)
	debug += i + " -> "+myObj[i]+"\n";

alert(debug);


附件中是输出的结果...

你可能感兴趣的:(JavaScript,java,html)