声明变量,生成随机数,键值对,es6定义变量
声明变量
var a={}
var a=new a()
生成随机数
console.log(Math.random()*(max-min)+min)
console.log(Math.random())生成0-1随机数
console.log(Math.random()*10+80)生成80-90随机数 {max-min是得到了0-10的随机数,再加80就得到了80-90
键值对
键名:key
键值:value
for (var key in xiaoMing){
console.log(key,xiaoMing[key])
},xiaoMing[key]就是键值
定义变量
let定义:let 声明的变量只在 let 命令所在的代码块内有效。let 声明的变量只在 let 命令所在的代码块 {} 内有效,在 {} 之外不能访问。
const定义数组:主要用于定义变量为常类型以及修饰函数参数与返回值,定义全局变量,const 声明一个只读的常量,一旦声明,常量的值就不能改变
Math取数
Math.round(1.1)//四舍五入 Math.ceil(1.1)//向上取整 Math.floor(1.9)//向下取整
浙公网安备 33010602011771号