Home  >  Article  >  Web Front-end  >  js data type

js data type

高洛峰
高洛峰Original
2016-10-08 16:24:101132browse

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用来表示尚未存在的对象,常用来表示函数企图返回一个不存在的对象


Statement:
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