1、typeof详细解析地址:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/typeof
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
//Number
console.log(typeof 37);//输出Number
console.log(typeof 3.14);//输出Number
console.log(typeof Math.LN2);//输出Number
console.log(typeof Infinity);//输出Number
console.log(typeof NaN);//输出Number
//string
console.log(typeof "");//输出string
console.log(typeof "qishuixian");//输出string
console.log(typeof "111");//输出string
//booleans
console.log(typeof true);//输出boolean
console.log(typeof false);//输出boolean
//symbol
console.log(typeof Symbol());//输出symbol
console.log(typeof Symbol('foo'));//输出symbol
console.log(typeof Symbol.iterator);输出symbol
// Undefined
console.log(typeof undefined); //输出undefined
console.log(typeof declaredButUndefinedVariable); //输出undefined
console.log(typeof undeclaredVariable); //输出undefined
// Objects
console.log(typeof {a:1})//输出object;
console.log(typeof [1, 2, 4])//输出object;
console.log(typeof new Date())//输出object;
// function
console.log(typeof function(){})//输出function;
console.log(typeof Math.sin)//输出function;
</script>
</body>
</html>
2、instanceof 详细解析地址 https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/instanceof
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
console.log("instanceof运算符用来测试一个对象在其型链中是否存在一个构造函数的prototype");
//定义构造函数
function C(){};
function D(){};
var o=new C();
console.log(o instanceof C);//true
console.log(o instanceof D);//false
C.prototype = {};
var o2 = new C();
console.log(o2 instanceof C); // true
D.prototype = new C(); // 继承
var o3 = new D();
console.log(o3 instanceof D); // true
console.log(o3 instanceof C); // true
</script>
</body>
</html>