JS—typeof、基本数据类型、数学函数——第三天
时间:2021-04-28 12:17:27
收藏:0
阅读:0
一、typeof 检测出来的数据类型
--> 基本数据类型
- string
- number
- boolean
- null
- undefined
--> 变量初始化了,但是没有赋值
--> 函数没有传实参,那么形参是undefined
--> 函数没有返回值,那么函数调用完的地方是undefined
--> 复杂数据类型
- function
- object
二、类型转换
1、parseInt() —— 转换为整数,一位一位地看
2、parseFloat() —— 转换为小数, 一位一位地看
3、Number() —— 转换为数值(包括小数),整体看,非数值为 NaN
--> 判断是不是非数字,用 isNaN() —— 判断是不是NaN;NaN 不等于 NaN;NaN 是 Number 类型。
三、数学函数
1、Math.random() 随机数 0--1(不包含1)之间的数
--> parseInt( Math.random() * (m-n) + n)
评论(0)