前言

我是歌谣 我有个兄弟 巅峰的时候排名c站总榜19 叫前端小歌谣 曾经我花了三年的时间创作了他 现在我要用五年的时间超越他 今天又是接近兄弟的一天人生难免坎坷 大不了从头再来 歌谣的意志是永恒的 放弃很容易 但是坚持一定很酷 本题目源自于牛客网 微信公众号前端小歌谣

题目

请补全JavaScript代码,要求以Boolean的形式返回第一个实例参数是否在第二个函数参数的原型链上。

#yyds干货盘点# 前端歌谣的刷题之路-第一百六十六题-instanceOf_html

#yyds干货盘点# 前端歌谣的刷题之路-第一百六十六题-instanceOf_html_02编辑

 核心代码

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>instanceof</title>
</head>

<body>
<script type="text/javascript">
const _instanceof = (target, Fn) => {
// 补全代码
let proto = target.__proto__

while (true) {
if (proto === Fn.prototype) return true
if (proto === null) return false
proto = proto.__proto__
}
}
</script>
</body>

</html>

#yyds干货盘点# 前端歌谣的刷题之路-第一百六十六题-instanceOf_javascript_03