JavaScript 内置对象:Math -------Math 对象不是构造函数
例: console.log(Math.max(1, 99, 3)); // 99
例: console.log(Math.max(1, 99, 'pink老师')); // NaN
console.log(Math.abs('-1')) -- 隐式转换,把字符串的转为数字型,结果绝对值
例: console.log(Math.abs('-1')); // 隐式转换 会把字符串型 -1 转换为数字型
例:console.log(Math.round(1.5)); // 2
console.log(Math.round(-1.5)); // 这个结果是 -1
例: console.log(Math.floor(1.9)); // 1
例:console.log(Math.ceil(1.1)); // 2
Math.random() -- 返回:大于0的,小于1 的随机数。
function getSuiji(min,max){
return Math.floor(Math.random() * (max - min + 1) + min);
}
getSuiji(10,20);


浙公网安备 33010602011771号