您的位置:首页 > Web前端 > JavaScript

JavaScript数据类型

2016-02-01 21:19 741 查看
VariableExplanationExample
StringA string of text. To signify that the variable is a string, you should enclose it in quote marks.
var myVariable = 'Bob';
NumberA number. Numbers don't have quotes around them.
var myVariable = 10;
BooleanA True/False value. The words
true
and
false
are special keywords in JS, and don't need quotes.
var myVariable = true;
ArrayA structure that allows you to store multiple values in one single reference.
var myVariable = [1,'Bob','Steve',10];
Refer to each member of the array like this:
myVariable[0]
,
myVariable[1]
, etc.
ObjectBasically, anything. Everything in JavaScript is an object, and can be stored in a variable. Keep this in mind as you learn.
var myVariable = document.querySelector('h1');
All of the above examples too
总结:

JavaScript共有五种数据类型:

字符串

数字

布尔类型

数组

对象 (javascript中的所有东西都是一个对象)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: