js数据类型汇总
- number:
整数和浮点数 - string:字符串
- boolean:布尔类型
- null:空值
- undefined:未定义
- obj:对象,各种值组成的集合
typeof示例
// number var n_int = 1; var n_float = 3.14; console.log('n_int:', typeof(n_int)); console.log('n_float:', typeof(n_float)); // string var string = 'Hello World'; console.log('string:', typeof(string)); // boolean var bl = true; console.log('bl:', typeof(bl)); // symbol var s = Symbol(); console.log('s:', typeof(s)); // null var nothing = null; console.log('nothing:', typeof(nothing)); // undefine var udf console.log('udf:', typeof(udf)); // object var arr = [1, 2, 3]; var func = () => {
console.log('---function func---'); } var obj = {
a: 1, b: 'this is string' } console.log('arr:', typeof(arr)); console.log('func:', typeof(func)); console.log('obj:', typeof(obj));
输出:
n_int: number n_float: number string: string bl: boolean s: symbol nothing: object udf: undefined arr: object func: function obj: object
typeof的输出汇总
- number
- string
- boolean
- object
- function
- undefined
- symbol
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/210968.html原文链接:https://javaforall.net
