<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
//就是判断对象的原型链(__proto__)和构造函数的protorype指的是不是同一个对象
function P(){}
let p = new P
console.log(p instanceof P) //true
console.log(p instanceof Object) //true
//所以不能得出自己真正的构造函数是谁
console.log(p instanceof Array) //false
</script>
</body>
</html>
instanceof到底怎么判断的
最新推荐文章于 2023-03-01 11:09:21 发布