目录
1.JavaScriptP的数据类型
基本数据类型:
1.Unde_
2.Null
3.Number
4.Number
5.String
复杂数据类型
Object
(ES6新增了symbol数据类型)
2.typeof操作符
功能 | 检测变量类型 |
语法 | typeof变量或者typeof(变量) |
返回值 | string类型,可能是: string、number、boolean、object、undefined、function |
var name_01="marry",age=18,email="marry@sina.com.cn" ,address;
console.log(typeof (name_01))//在控制台中打印
console.log(typeof (age))
3.Undefined(没有定义)
- undefined类型只有一个值,即特殊的undefined。
说明:一般而言,不存在需要显示地把一个变量设置为undefined值的情况。
// 一次声明多变量
var name_01="marry",age=18,email="marry@sina.com.cn" ,address;
console.log(typeof (name_01))//在控制台中打印
console.log(typeof (age))
console.log(typeof (number))
4.Null
1.null值表示一个空对象指针
2.如果定义的变量准备在将来用于保存对象,那么最好将改变量初始化为null而不是其他值。
settings=null;
注:undefined值是派生类自null值的,所以undefined= =null的值返回结果是true。