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
来源:博客网 转载请注明出处!