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. K8s 二、(1、kubeadm部署Kubernetes集群)

    准备工作 满足安装 Docker 项目所需的要求,比如 64 位的 Linux 操作系统.3.10 及以上的内核版本: x86 或者 ARM 架构均可: 机器之间网络互通,这是将来容器之间网络互通的前 ...

  2. 解决java.lang.NoClassDefFoundError: ch/qos/logback/core/joran/spi/Pattern

    明明引入了这个,却提示没有 看下面文章: http://www.maocaoying.com/article/109

  3. mapreduce编程练习(一)简单的练习 WordCount

    入门训练:WordCount 问题描述:对一个或多个输入文件中的单词进行计数统计,比如一个文件的输入文件如下 输出格式: 运行代码实例: package hadoopLearn; import jav ...

  4. (15)Linux命令基本格式

    1.命令提示符 登录系统后,第一眼看到的内容是: [root@localhost ~]# 这就是 Linux 系统的命令提示符.那么,这个提示符的含义是什么呢? []:这是提示符的分隔符号,没有特殊含 ...

  5. cassandra权威指南读书笔记--Cassandra架构(3)

    分阶段事件驱动架构 SEDASEDA(Staged Event-Driven Architecture)的核心思想是把一个请求处理过程分成几个Stage,不同资源消耗的Stage使用不同数量的线程来处 ...

  6. c++11新特性实战(二):智能指针

    c++11添加了新的智能指针,unique_ptr.shared_ptr和weak_ptr,同时也将auto_ptr置为废弃(deprecated). 但是在实际的使用过程中,很多人都会有这样的问题: ...

  7. Elasticsearch 之 Filter 与 Query 有啥不同?

    今天来了解下 Elasticsearch(以下简称 ES) 中的 Query 和 Filter. 在 ES 中,提供了 Query 和 Filter 两种搜索: Query Context:会对搜索进 ...

  8. 翻译:《实用的Python编程》00_Setup

    课程设置与概述 欢迎访问本课程(Practical Python Programming).这个页面包含一些关于课程设置的重要信息. 课程周期和时间要求 该课程最初是作为一个由讲师主导的,持续 3 - ...

  9. Eclipse无法查看Servlet源代码的解决方案

    在Apache官方网站中选择你对应的tomacat版本下载对应的Tomcat的源码 下载Source Code Distributions下的zip 将下载的zip文件复制到lib文件夹下 在提示页面 ...

  10. Codeforces Round #650 (Div. 3) B. Even Array

    题目链接:https://codeforces.com/contest/1367/problem/B 题意 有一大小为 $n$ 的数组 $a$,问能否经过交换使所有元素与下标奇偶性相同(0 - ind ...