javascript - 为什么JS中的bind方法返回的函数没有prototype值?

查看:141
本文介绍了javascript - 为什么JS中的bind方法返回的函数没有prototype值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

如题

function func () {}
console.log(func.prototype) // Object {}

var fn = func.bind(this)
console.log(fn.prototype)  // undefined ?

解决方案

emca-262里面这么说

https://www.ecma-internationa...

19.2.3.2
NOTE 1
Function objects created using Function.prototype.bind are exotic objects. They also do not have a prototype property.

exotic :奇异的特别的

19.2.4.3
Function objects created using Function.prototype.bind, or by evaluating a MethodDefinition (that are not a GeneratorMethod) or an ArrowFunction grammar production do not have a prototype property.

箭头函数也没有

这篇关于javascript - 为什么JS中的bind方法返回的函数没有prototype值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆