首页 > Web开发 > 详细

js六种数据类型

时间:2019-09-27 18:23:56      阅读:83      评论:0      收藏:0      [点我收藏+]

六种数据类型:

  undefined 、 boolean  、string 、number 、object 、function

技术分享图片

 

 效果地址:https://scrimba.com/c/cEedDGTd

代码:

var a;
console.log(typeof a);  // undefined

var b=true;
console.log(typeof b);  // boolean

var c=‘我是字符串‘;
console.log(typeof c);  // string

var d=3;
console.log(typeof d);  // number

// 创建object的第一种方法
var e1=new Object();  
e1.name = ‘小猫咪‘; 
console.log(typeof e1);  // object
// 创建object的第二种方法
var e2={              
    name: ‘ha‘
}
console.log(typeof e2);  // object
// null
var e_null = null;   
console.log(typeof e_null); // object
// array 数组
var e_array=[1,3,5]   
console.log(typeof e_array);  // object

function add(){
    return 1;
}
console.log(typeof add);  // function

 

js六种数据类型

原文:https://www.cnblogs.com/FlyingLiao/p/11599373.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!