本文介绍了JavaScript中的原始数据类型和非原始数据类型之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法准确理解JavaScript中原始数据类型和非原始数据类型之间的区别,即使它使用相同的名称声明,即var。
I am not able to understand exactly what is difference between primitive and non primitive data types in JavaScript even it is declared using same name i.e var.
推荐答案
Data Types (JavaScript):
Primary Data Types
The primary (primitive) data types are:
String, Number, Boolean
Composite Data Types
The composite (reference) data types are:
Object, Array
Special Data Types
The special data types are:
Null, Undefined
点击了解详情:
var test1 = 1;
var test2 = "Something";
var test3 = true;
var test4 = {};
var test5 = new Array();
var test6 = new Date();
var test7;
var test8 = null;
alert(typeof (test1)); //number
alert(typeof (test2)); //string
alert(typeof (test3)); //boolean
alert(typeof (test4)); //object
alert(typeof (test5)); //object
alert(typeof (test6)); //object
alert(typeof (test7)); //undefined
alert(typeof (test8)); //object
这篇关于JavaScript中的原始数据类型和非原始数据类型之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!