js in depth: arrow function & prototype & this & constructor
js in depth: arrow function & prototype & this & constructor
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
https://hacks.mozilla.org/2015/06/es6-in-depth-arrow-functions/
https://stackoverflow.com/questions/31755186/es6-arrow-functions-not-working-on-the-prototype
https://www.sitepoint.com/es6-arrow-functions-new-fat-concise-syntax-javascript/
proptotype bug

https://teamtreehouse.com/community/does-arrow-function-syntax-works-for-prototype
const log = console.log;
// 1. constructor bug
const func = () => {
this.name = `xgqfrms`;
title = `arrow function`;
log(`this.name`, this.name);
};
log(`\nfunc`, func);
log(`\nfunc.prototype`, func.prototype);
// func.prototype undefined
// 2. prototype bug
func.prototype.print = function () {
let name = this.name;
log(`\nname =`, name);
};
// TypeError: Cannot set property 'print' of undefined
// const obj = {
// name: "webgeeker",
// };
// log(`\nfunc =`, func);
// log(`\nfunc.print =`, func.print);
constructor bug
arrow function constructor
arrow functions have no 'this',

原型链 继承 & 构造函数 继承
https://www.cnblogs.com/hejun26/p/10910590.html



xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
js in depth: arrow function & prototype & this & constructor的更多相关文章
- js in depth: Object & Function & prototype & __proto__ & constructor & classes inherit
js in depth: Object & Function & prototype & proto & constructor & classes inher ...
- js in depth: closure function & curly function
js in depth: closure function & curly function 闭包, 科里化 new js 构造函数 实例化, 不需要 new var num = new Ar ...
- js中Object.__proto__===Function.prototype
参考:http://stackoverflow.com/questions/650764/how-does-proto-differ-from-constructor-prototype http:/ ...
- JS 中的 __proto__ 、prototype、constructor
首先 先解释这三个属性: (1) prototype : 它是函数独有的,从一个函数指向一个对象(函数的原型),含义是函数的原型对象,也就是这个函数所创建的实例的原型对象.(普通函数的该属性没有作用 ...
- JS 一张图理解prototype、proto和constructor的关系
转载于原文地址:https://www.cnblogs.com/xiaohuochai/p/5721552.html(感谢大神的总结) 前面的话 javascript里的关系又多又乱.作用域链是一种单 ...
- Prototype and Constructor in JavaScript
The concept of prototype in JavaScript is very confusing, especially to those who come with a C++/JA ...
- 推断js中的类型:typeof / instanceof / constructor / prototype
怎样推断js中的类型呢,先举几个样例: var a = "jason"; var b = 123; var c = true; var d = [1,2,3]; var e = n ...
- js中prototype,constructor的理解
连看4篇前辈的文章,记录一些知识点 Javascript继承机制的设计思想 Javascript 面向对象编程(一):封装 Javascript面向对象编程(二):构造函数的继承 Javascript ...
- 关于JS call apply 对象、对象实例、prototype、Constructor、__proto__
关于call与apply的理解容易让人凌乱,这里有个方法可供参考 tiger.call(fox,arg1,arg2...) tiger.apply(fox,[arg1,arg2...]) 理解为 fo ...
随机推荐
- 用好Java中的枚举真的没有那么简单
1.概览 在本文中,我们将看到什么是 Java 枚举,它们解决了哪些问题以及如何在实践中使用 Java 枚举实现一些设计模式. enum关键字在 java5 中引入,表示一种特殊类型的类,其总是继承j ...
- python——模块、标准库、第三方模块安装
模块(module)简介 模块化--指将一个完整的程序分解为一个一个小的模块,通过将模块组合,来搭建出一个完整的程序. 模块化的特点: ① 方便开发 ② 方便维护 ③ 模块可以复用! 在Python中 ...
- python中如何添加模块导入路径?
python中自定义模块导入路径的方式主要有以下3种: (1)使用sys.path.append() 随着程序执行,会动态地添加模块导入的路径,但是程序执行结束后就会立即失效(临时性的) import ...
- 设计模式(三)——Java工厂方法模式
工厂方法模式 1 看一个新的需求 披萨项目新的需求:客户在点披萨时,可以点不同口味的披萨,比如 北京的奶酪 pizza.北京的胡椒 pizza 或者是伦敦的奶酪 pizza.伦敦的胡椒 pizza. ...
- linux虚拟摄像头vivid配置
总述 最近在看摄像头驱动,需要配置虚拟摄像头的驱动,但是教程里面是linux2.6内核的,实际电脑的是Ubuntu16,内核是linux4.15版本,从2.6到4.15内核好多文件发生了变化,所 ...
- 【noi 2.5_1792】迷宫(bfs 或 dfs)
简单搜索,在n*n的矩阵中,问从起点是否可以到达终点,有些格子不可走,上下左右四个方向都可以走.(N<=100)1.bfs从起点开始走,直到走到终点或全部遍历过一次就结束.2.dfs要一走到终点 ...
- codeforces251A. Points on Line
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. N ...
- PowerShell启用多跳远程控制
有些场景下,我们使用远程连接了某个Server,在远程Server中再想进行远程操作,就会提示错误.因为默认的认证信息只会传递一跳. 对此,微软官方文档给出的解决方案是:https://docs.mi ...
- LVS-DR 模式
SNAT(Source Network Address Translation)源地址转换,类似家里路由器设置,内网地址向外访问时,发起访问的内网ip地址转换为指定的 IP 地址 DNAT(Desti ...
- MySQL 主从复制(上)
目录 主从复制前提 主从复制原理 涉及的文件 & 线程 Master 主库 Slave 从库 主从复制的搭建 主库配置 配置 /etc/my.cnf 建立专用复制用户 查看 Binlog 信息 ...