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

https://teamtreehouse.com/community/why-cant-we-use-arrow-functions-when-defining-the-constructor-function

arrow functions have no 'this',

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#No_separate_this



原型链 继承 & 构造函数 继承

https://www.cnblogs.com/hejun26/p/10910590.html




xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


js in depth: arrow function & prototype & this & constructor的更多相关文章

  1. js in depth: Object & Function & prototype & __proto__ & constructor & classes inherit

    js in depth: Object & Function & prototype & proto & constructor & classes inher ...

  2. js in depth: closure function & curly function

    js in depth: closure function & curly function 闭包, 科里化 new js 构造函数 实例化, 不需要 new var num = new Ar ...

  3. js中Object.__proto__===Function.prototype

    参考:http://stackoverflow.com/questions/650764/how-does-proto-differ-from-constructor-prototype http:/ ...

  4. JS 中的 __proto__ 、prototype、constructor

    首先 先解释这三个属性: (1) prototype  : 它是函数独有的,从一个函数指向一个对象(函数的原型),含义是函数的原型对象,也就是这个函数所创建的实例的原型对象.(普通函数的该属性没有作用 ...

  5. JS 一张图理解prototype、proto和constructor的关系

    转载于原文地址:https://www.cnblogs.com/xiaohuochai/p/5721552.html(感谢大神的总结) 前面的话 javascript里的关系又多又乱.作用域链是一种单 ...

  6. Prototype and Constructor in JavaScript

    The concept of prototype in JavaScript is very confusing, especially to those who come with a C++/JA ...

  7. 推断js中的类型:typeof / instanceof / constructor / prototype

    怎样推断js中的类型呢,先举几个样例: var a = "jason"; var b = 123; var c = true; var d = [1,2,3]; var e = n ...

  8. js中prototype,constructor的理解

    连看4篇前辈的文章,记录一些知识点 Javascript继承机制的设计思想 Javascript 面向对象编程(一):封装 Javascript面向对象编程(二):构造函数的继承 Javascript ...

  9. 关于JS call apply 对象、对象实例、prototype、Constructor、__proto__

    关于call与apply的理解容易让人凌乱,这里有个方法可供参考 tiger.call(fox,arg1,arg2...) tiger.apply(fox,[arg1,arg2...]) 理解为 fo ...

随机推荐

  1. maven pom文件的 name 标签 和 url标签到底是什么作用

  2. react报错 TypeError: Cannot read property 'setState' of undefined

    代码如下: class test extends Component { constructor(props) { super(props); this.state = { liked: false ...

  3. spark SQL (五)数据源 Data Source----json hive jdbc等数据的的读取与加载

    1,JSON数据集 Spark SQL可以自动推断JSON数据集的模式,并将其作为一个Dataset[Row].这个转换可以SparkSession.read.json()在一个Dataset[Str ...

  4. linux 文件目录解释笔记(未完待续...)

    目录 应放置档案内容 /bin 系统有很多放置执行档的目录,但/bin比较特殊.因为/bin放置的是在单人维护模式下还能够被操作的指令. 在/bin底下的指令可以被root与一般帐号所使用,主要有:c ...

  5. Cisco交换机管理员配置

    conf tservice timestamps debug datetime msec localtime yearservice timestamps log datetime msec loca ...

  6. HDU 6762 Mow (2020 Multi-University Training Contest 1 1012) 半平面交

    Mow 题目链接 分析 将多边形的边向内部缩 r 个单位长度,然后这些边所围成的内部区域,就是圆心的合法范围,该范围也是一个多边形,假设面积是\(a\),周长是\(b\),那么可以知道圆可以覆盖的面积 ...

  7. 2020牛客暑期多校训练营(第四场) C - Count New String (字符串,广义后缀自动机,序列自动机)

    Count New String 题意: 定义字符串函数 \(f(S,x,y)(1\le x\le y\le n)\),返回一个长度为y-x+1的字符串,第 i 位是 \(max_{i=x...x+k ...

  8. 【洛谷 p3390】模板-矩阵快速幂(数论)

    题目:给定n*n的矩阵A,求A^k. 解法:利用矩阵乘法的定义和快速幂解答.注意用负数,但是数据太弱没有卡到我......(P.S.不要在 typedef long long  LL; 前使用 LL. ...

  9. zjnu1725 COCI (类似二维树状数组模拟)

    Description The 3rd round of COCI is already here! In order to bet on predict the scores, we have as ...

  10. Leetcode】周赛203 查找大小为M的最新分组

    题意: 给你一个数组 arr ,该数组表示一个从 1 到 n 的数字排列.有一个长度为 n 的二进制字符串,该字符串上的所有位最初都设置为 0 . 在从 1 到 n 的每个步骤 i 中(假设二进制字符 ...