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. Windows10 通过 ssh 映射 Linux 为盘符

    一. 安装WinFsp 地址 选择.msi文件下载并安装 二. 安装SSHFS-Win 地址 点击下载64位安装包, 然后安装 三.挂载Linux文件夹 1.映射网络驱动器 输入用户名, 服务器ip地 ...

  2. springBoot controller入参LocalDateTime

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss") @DateTimeForma ...

  3. Java并发练习

    1.按顺序打印ABC 三个线程,每个线程分别打印A,B,C各十次,现在要求按顺序输出A,B,C package concurrency; import java.util.concurrent.Exe ...

  4. Spring Cloud,Docker书籍资源、优秀博文等记录

    Spring Cloud,Docker书籍资源.优秀博文等记录 Spring Cloud,Docker书籍资源.优秀博文等记录 一.书籍 二.博文地址 三.思维导图Or图片 3.1一张图总结 Dock ...

  5. 狂神说SpringBoot11:Thymeleaf模板引擎

    狂神说SpringBoot系列连载课程,通俗易懂,基于SpringBoot2.2.5版本,欢迎各位狂粉转发关注学习. 微信公众号:狂神说(首发)    Bilibili:狂神说Java(视频) 未经作 ...

  6. Scrambled Polygon POJ - 2007 极角排序

    题意: 给你n个点,这n个点可以构成一个多边形(但是不是按顺序给你的).原点(0,0)为起点,让你按顺序逆序输出所有点 题解: 就是凸包问题的极角排序 用double一直Wa,改了int就可以了 // ...

  7. zjnu1762 U (线段树)

    Description Mirko is hungry as a bear, scratch that, programmer and has stumbled upon a local restau ...

  8. hdu3905 Sleeping (区间dp)

    Problem Description ZZZ is an enthusiastic ACMer and he spends lots of time on training. He always s ...

  9. Codeforces Round #531 (Div. 3) E. Monotonic Renumeration (构造)

    题意:给出一个长度为\(n\)的序列\(a\),根据\(a\)构造一个序列\(b\),要求: ​ 1.\(b_{1}=0\) ​ 2.对于\(i,j(i\le i,j \le n)\),若\(a_{i ...

  10. [视频] Docker 安装 nginx + rtmp

    目录 拉取镜像 创建并运行容器,映射出两个端口1935.80 将视频文件推流至rtmp服务器 使用ffplay播放rtmp流 拉取镜像 docker pull alfg/nginx-rtmp 创建并运 ...