1.随机函数
//随机函数//Math.round() 四舍五入Math.round(Math.random());//区0-1之间的整数即0或1//0~10之间的整数Math.round( Math.random()*10);//5~10之间的整数Math.round( Math.random()*5+5);//20~100之间的整数Math.round( Math.random()*80+20);//x~y之间的整数Math.round( Math.random()*(y-x)+x);//0~x之间的整数Math.round( Math.random()*x);//1~xMath.ceil( Math.random()*x);
2.JSON
var json={"name":"leo","age":24};json.name;//leojson["nume"];//leovar imgData={imgUrl:["img/1.png","img/2.png","img/3.png","img/4.png"],txt:["图片一","图片二","图片三","图片四"]}imgData.imgUrl[0];//img/1.png//json遍历var json1={‘name‘:‘carol‘,‘age‘:18,‘fun‘:‘moile‘};for (var attr1 in json1) {//alert(attr1);alert(json1[attr1]);}
随机函数与JSON
原文地址:http://www.cnblogs.com/yangxue72/p/7975819.html