1.基本数据类型:
- number :数字类型
- string :字符串类型
- boolean:布尔类型
- undefined :未定义
- 空(null)
var a = 123; //number
var b = "Hello,word"; //string
var c = true; //boolean
var d // undefined
var e = null; //null
2.引用数据类型:
- Object :对象类型
- Array : 数组类型
- Function: 函数类型
var f = []; //Array
var g = {}; //Object
typeof( )返回的值有:
- function
- number
- string
- boolean
- undefined
- object
- symbol(ES6中新增)
console.log(typeof(d) ) //undefined
console.log(typeof( typeof(d) )) // String
console.log( typeof(e) ) // Object
console.log( typeof(f) ) // Object
console.log( typeof(g) ) // Object
var cc = function(){};
console.log(typeof(cc)); //function
typeof(Undefined) 返回是 Undefined;
typeof(Null)返回Object,但Null不是Object;
typeof(NaN)和typeof(Infinity)都返回number ;
小技巧:
在谷歌浏览器控制台中,数字和布尔类型是蓝色,字符串类型是黑色,null和undefined是浅灰色
本文地址:https://blog.csdn.net/Czm_cc/article/details/109586411
您可能感兴趣的文章:
- vue init初始化项目后 npm run dev报错 10% building modules 1/1 modules 0 activeevents
- axios 处理 302 状态码的解决方法
- [Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/feature
- react-native 在新版Xcode(10+)中运行出现的问题: node_modules/react-native/third-party/glog-0.3.4 , C compiler cannot create executables
- 使用puppeteer爬取网站并抓出404无效链接
- 【angular2+typeScript+ng-zorro】Carousel 走马灯的左右方向控件实现
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
网友评论