javascript - javascript 引用实例无法访问构造函数中的方法?
问题描述
function F(){
// NOP
};
F.methodF = function(){
// NOP
};
var f = new F();
f.__proto__
{constructor: ƒ}
constructor: ƒ F()
methodF: ƒ ()
length: 0
name: "F"
arguments: null
caller: null
prototype: {constructor: ƒ}
__proto__: ƒ ()
[[FunctionLocation]]: VM978:1
[[Scopes]]: Scopes[1]
__proto__: Object
F.methodF
ƒ (){
// NOP
}
f.methodF
undefined
如上所述,我很困惑 abort 以下内容: 1. 为什么 methodF 存储在构造函数中?2. 为什么instance f不能访问methodF?但 F 可以访问。
解决方案
推荐阅读
- rest - 从 DocuSign Rest API 调用 getDocument 时如何使用加密
- javascript - React 组件在状态更改时不刷新内容 [Next.js]
- python - Why Python Mysql Query doesn't show all the columns whereas Phpmyadmin does it very well?
- javascript - 相同的函数在 javascript 中以不同的方式编写
- loops - How to write recursive nested loop in vue.js template?
- r - 如何删除每个月出现次数少于 n 的个体?
- java - 构建映像失败,尝试创建 docker 映像时未找到摘要错误
- python - 如何获取用户输入并在 Python 的“for”循环中应用?
- tensorflow - 是否可以重新训练曾经训练过的张量流模型
- reactjs - 为什么组件重新渲染会强制网页重置滚动位置?