欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

javascript的typeof返回的数据类型

程序员文章站 2022-06-04 21:39:33
...

javascript的typeof返回的数据类型有:

  1. undefined
  2. string
  3. boolean
  4. number
  5. Object
  6. Function

示例:

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

//string
var a = "";
var b = "hello"
console.log(typeof a);
console.log(typeof b);

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

//number
var a = 15;
console.log(typeof a);

//object
var a = null;
var b = {};
var c = [];
console.log(typeof a);
console.log(typeof b);
console.log(typeof c);

//function
function fun1() {};
var fun2 = function () {};
console.log(typeof fun1);
console.log(typeof fun2);

相关标签: Web javascript