惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Register - Security
The Register - Security
Cisco Talos Blog
Cisco Talos Blog
P
Proofpoint News Feed
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
C
Check Point Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Y
Y Combinator Blog
V
Visual Studio Blog
H
Help Net Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
The Last Watchdog
The Last Watchdog
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Apple Machine Learning Research
Apple Machine Learning Research
SecWiki News
SecWiki News
博客园 - 叶小钗
V
Vulnerabilities – Threatpost
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
IT之家
IT之家
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
罗磊的独立博客
C
CXSECURITY Database RSS Feed - CXSecurity.com
V2EX - 技术
V2EX - 技术
T
The Blog of Author Tim Ferriss
小众软件
小众软件
The GitHub Blog
The GitHub Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
DataBreaches.Net
L
LINUX DO - 热门话题
大猫的无限游戏
大猫的无限游戏
V
V2EX
Latest news
Latest news
NISL@THU
NISL@THU
Last Week in AI
Last Week in AI
Spread Privacy
Spread Privacy
云风的 BLOG
云风的 BLOG
S
Secure Thoughts
W
WeLiveSecurity
S
Security @ Cisco Blogs
C
CERT Recently Published Vulnerability Notes
AWS News Blog
AWS News Blog
I
InfoQ
A
About on SuperTechFans
K
Kaspersky official blog
Security Latest
Security Latest
P
Proofpoint News Feed

博客园 - howhy

html 元素包含关系 this 指向 空对象 Object.keys for ...in Reflect.ownKeys ...区别 逻辑运算符和空值运算符 运算符优先级 js 类型显式转换 js 高级函数 js 方法重载 fetch timeout js 任务顺序执行 暂停 js 并发任务 判断两个对象是否相同 js 动态拦截属性 js 通用动画 js groupby js 防抖和节流 js 单例模式 js 数组去重和扁平方法 js 继承方法 js new的过程实现 js deepCopy js '=='的隐性类型转换规则
实现 instanceof 操作符
howhy · 2025-12-29 · via 博客园 - howhy
// 实现 instanceof 操作符
function myInstanceof(left, right) {
    // 实现
    if(typeof right!=='function' || right.constructor===null){
        throw new Error('right must be function');
    }
    if(left===null || typeof left!=='object' && typeof left!=='function'){
        return false;
    }
    let leftProto =Object.getPrototypeOf(left);
    while(true){
        if(leftProto===null){
            return false;
        }
        if(leftProto===right.prototype){
            return true;
        }
        leftProto=Object.getPrototypeOf(leftProto);
    }
}

posted @ 2025-12-29 14:24  howhy  阅读(20)  评论()    收藏  举报