js数据类型有几种?有什么不同

标签:2024-05-15 23:34:45

js的数据类型可分为基本数据类型和引用数据类型

基本数据类型(栈存储):Undefined,Null,Boolean,Number、String

引用数据类型(堆存储):对象、数组、函数

堆是先进先出,栈是先进后出

以下是js基本数据类型和引用类型的类型值示例:

let a = 10
let a2 = '10'
let a3 = null
let a4 = undefined
let a5 = true
let a6 = {id:1,value:'20'}
let a7 = [1,2,3,4,5,6]
let a8 = function(){
return '6'
}
console.log(typeof(a))  //number
console.log(typeof(a2))  //string
console.log(typeof(a3))  //object
console.log(typeof(a4))  //undefined
console.log(typeof(a5))  //boolean
console.log(typeof(a6))  //object
console.log(typeof(a7))  //object
console.log(typeof(a8))  //function
原文出处:http://www.dongblog.com/notes/52.html
来源:博客网 转载请注明出处!

活跃用户

发奋图强的不入流程序猿
Ta还没有签名
████
Ta还没有签名
い散落漫天回忆的碎片
Ta还没有签名
WSL
Ta还没有签名

友情链接


Warning: Smarty error: unable to read resource: "../../../templates/default/./common/foot/footer_index.htm" in /usr/home/hyu3925200001/htdocs/common/smarty/Smarty.class.php on line 1093

Warning: Smarty error: unable to read resource: "../../../templates/default/./common/foot/footer_index.htm" in /usr/home/hyu3925200001/htdocs/common/smarty/Smarty.class.php on line 1093