a_gust_wind 2022-08-02 18:38 采纳率: 55.6%
浏览 13

关于js f1.bind(obj)返回的函数的原型对象是undefined


function f1(){
}
let obj = {name:'lisi'};
let res = f1.bind(obj);
let ob1 = new res();
console.log(ob1 instanceof res,ob1 instanceof f1,res.prototype,ob1__proto__===f1.prototype)
//true true    undefined true

res.prototype对象为undefined,照理使用instanceof就会报错,这里没报错 实例ob1还是res的实例 为什么呢 ob1原型链上根本没有res的原型

这又是如何实现的呢

function f2(){}
let ob2 = new f2();
f2.prototype = undefined;
console.log(ob2 instanceof f2)//报错语法检查右边f2的原型对象为undefined
console.log(f2.isPrototypeof(ob2))//为false


  • 写回答

1条回答 默认 最新

  • 关注

    【【面试题】javascript中的原型与原型链-哔哩哔哩】 https://b23.tv/eEc2xEE

    评论

报告相同问题?

问题事件

  • 修改了问题 8月2日
  • 创建了问题 8月2日

悬赏问题

  • ¥15 is not in the mmseg::model registry。报错,模型注册表找不到自定义模块。
  • ¥15 安装quartus II18.1时弹出此error,怎么解决?
  • ¥15 keil官网下载psn序列号在哪
  • ¥15 想用adb命令做一个通话软件,播放录音
  • ¥30 Pytorch深度学习服务器跑不通问题解决?
  • ¥15 部分客户订单定位有误的问题
  • ¥15 如何在maya程序中利用python编写领子和褶裥的模型的方法
  • ¥15 Bug traq 数据包 大概什么价
  • ¥15 在anaconda上pytorch和paddle paddle下载报错
  • ¥25 自动填写QQ腾讯文档收集表