分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 教程案例

随机函数与JSON

发布时间:2023-09-06 01:28责任编辑:沈小雨关键词:暂无标签

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

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved