js & object & prototype & __proto__ & prototype chain
js & object & prototype & proto & prototype chain
constructor prototype === instance proto
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype
let log = console.log;
function Foo() {
name: "Foo";
}
// var foo = new Foo();
let foo = new Foo();
log(Foo.name);
log(foo.name);
log(`Foo.prototype =`, Foo.prototype);
log(`foo.prototype =`, foo.prototype);
log(`Foo.__proto__ =`, Foo.__proto__);
log(`foo.__proto__ =`, foo.__proto__);
log(`Foo.prototype === foo.__proto__`, Foo.prototype === foo.__proto__);
"use strict";
/**
*
* @author xgqfrms
* @license MIT
* @copyright xgqfrms
* @created 2019-08-16
*
* @description prototype-chain (prototype & __proto__ )
* @augments
* @example
* @link https://hackernoon.com/understand-nodejs-javascript-object-inheritance-proto-prototype-class-9bd951700b29
*
*/
let log = console.log;
function Foo() {
name: "Foo";
}
// var foo = new Foo();
let foo = new Foo();
log(Foo.name);
// Foo
log(foo.name);
// undefined
log(`Foo.prototype =`, Foo.prototype);
// {constructor: ƒ}
// constructor: ƒ Foo()
// __proto__: Object
log(`foo.prototype =`, foo.prototype);
// undefined
log(`Foo.__proto__ =`, Foo.__proto__);
// ƒ () { [native code] }
log(`foo.__proto__ =`, foo.__proto__);
// {constructor: ƒ}
// constructor: ƒ Foo()
// __proto__: Object
log(`Foo.prototype === foo.__proto__`, Foo.prototype === foo.__proto__);
// true
https://stackoverflow.com/questions/9959727/proto-vs-prototype-in-javascript
https://www.freecodecamp.org/news/prototype-in-js-busted-5547ec68872/
( new Foo ).__proto__ === Foo.prototype;
( new Foo ).prototype === undefined;
function Point(x, y) {
this.x = x;
this.y = y;
}
var myPoint = new Point();
// the following are all true
myPoint.__proto__ == Point.prototype
myPoint.__proto__.__proto__ == Object.prototype
myPoint instanceof Point;
myPoint instanceof Object;
xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
js & object & prototype & __proto__ & prototype chain的更多相关文章
- Object.prototype.__proto__, [[prototype]] 和 prototype
Object.prototype.__proto__ , [[prototype]] 和 prototype Object.prototype.__proto__ 是什么? __proto__ 是一个 ...
- constructor __proto__ prototype
js里面constructor __proto__ prototype这三个属性比较难理解,在重点研究这三个属性后,在这里做一个笔记, constructor:构造器,每个对象都有这个属性,他指向构 ...
- 再次理解JS的prototype,__proto__和constructor
个人总结: 下面这篇文章很好的讲解了js原型,原型链,个人的总结是要记住这三个属性 prototype.__proto__和constructor 首先明确,js中一切都是对象object(A). ( ...
- Object & prototype & __proto__ All In One
Object & prototype & proto All In One js 原型,原型链,原型对象 const obj ={}; // {} const obj = new Ob ...
- prototype chain & prototype & __proto__
prototype chain & prototype & proto prototype chain MDN https://developer.mozilla.org/en-US/ ...
- JavaScript:Function/Object/prototype/__proto__
console.log(Object.__proto__===Function.prototype); //true console.log(Object.prototype.__proto__); ...
- 彻底搞懂js __proto__ prototype constructor
在开始之前,必须要知道的是:对象具有__proto__.constructor(函数也是对象固也具有以上)属性,而函数独有prototype 在博客园看到一张图分析到位很彻底,这里共享: 刚开始看这图 ...
- js 如何打印出 prototype 的查找路径
js 如何打印出 prototype 的查找路径 Function function func (name) { this.name = name || `default name`; } f = n ...
- javascript prototype __proto__区别
An Object's __proto__ property references the same object as its internal [[Prototype]] (often refer ...
随机推荐
- Map类型数据导出Excel--poi
https://blog.csdn.net/KevinChen2019/article/details/101064790 <dependency> <groupId>org. ...
- Python基础(列表中变量与内存关系)
在Python中,copy的是内存地址,引用的是列表的引用地址,列表里存的是各个元素的地址 例如: name = [1,2,3,4,['xfxing','summer',6]] n2 = name.c ...
- 20201101gryz模拟赛解题报告
写在前面 2020rp++ 停课的第一场模拟赛 拿上一年的上一年的day1来考的, 结果得分期望220pts,实际135pts,rank3,太菜了 考着考着机房灯突然灭了,当时慌的一批 以为断电代码要 ...
- JVM 线上故障排查
JVM 线上故障排查 Linux 1.1 CPU 1.2 内存 1.3 存储 1.4 网络 一.CPU 飚高 寻找原因 二.内存问题排查 三.一般排查问题的方法 四.应用场景举例 4.1 怎么查看某个 ...
- 向指定url发送Get/Post请求
向指定url发送Get/Post请求 1.向指定url发送Get/Post请求 2.HttpUtil 工具类–向指定url发送Get/Post请求 1.向指定url发送Get/Post请求 impor ...
- OSPF优化
1.点对点(背靠背)的优化 两台设备直连(逻辑上的直连). 将OSPF宣告接口配置为点对点模式,不用选举DR.减少20S时间 interface Ethernet0/1 ip ospf network ...
- 腾讯云TcaplusDB获新加坡MTCS最高等级安全认证
近日,经过国际权威认证机构DNV GL的全面评估审核,TcaplusDB获得了新加坡多层云安全(以下简称"MTCS")T3级最高等级认证,这标志着TcaplusDB全面满足了新加坡 ...
- Pytest(12)pytest缓存
前言 pytest 运行完用例之后会生成一个 .pytest_cache 的缓存文件夹,用于记录用例的ids和上一次失败的用例. 方便我们在运行用例的时候加上--lf 和 --ff 参数,快速运行上一 ...
- hdu 3974 Assign the task(dfs序上线段树)
Problem Description There is a company that has N employees(numbered from 1 to N),every employee in ...
- zjnu1745 DOMINE (状压dp+1*2铺砖)
Description Mirko has a chessboard with N rows and just three columns. Slavica has written an intege ...