Home > Web Front-end > JS Tutorial > body text

js data type

高洛峰
Release: 2016-10-08 16:24:10
Original
1092 people have browsed it

js数据类型有以下几种
字符串、数字、布尔、数组、对象、Null、Undefined
字符串  
  var carname="Bill Gates";
数字    
  var x=34;
布尔    
  var x=true或者var y=false
数组
  var cars=new Array();
  cars[0]="Audi";
  cars[1]="BMW";
  cars[2]="Volvo";
  var cars=new Array("Audi","BMW","Volvo");
  var cars=["Audi","BMW","Volvo"];
对象
  var person={firstname:"Bill", lastname:"Gates", id:5566};
Null、Undefined
  Undefined表示变量被声明了,但没有赋值,当声明的变量还未被初始化时,变量的默认值为undefined
  null用来表示尚未存在的对象,常用来表示函数企图返回一个不存在的对象
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!