js instanceof用法
时间: 2023-10-09 09:13:06 浏览: 80
在JavaScript中,instanceof是用来判断一个对象是否是某个构造函数的实例化对象的。它的使用方法是通过左侧对象使用instanceof关键字,后面跟上右侧的构造函数。如果左侧对象在其原型链上能够找到右侧构造函数的原型对象,那么返回true,否则返回false。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [【JavaScript】instanceof的详细用法](https://blog.csdn.net/qq_41612593/article/details/116020671)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [详解JS中的instanceof使用及手写instanceof](https://blog.csdn.net/qq_40868156/article/details/124688170)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文