遍历对象

syntax 语法

遍历对象

var test = {
			//var a = 1; 对象里这样写是错的
			a:1,b:2,c:
			function (){
				alert("c");
			}
			
		}
		for (var p in test){
			if(typeof(test[p]) == "function"){
				test[p]();
			}else{
				alert(test[p]);
			}
		}

猜你喜欢

转载自xiaoxiaoher.iteye.com/blog/2347852