"The JavaScript You Don't Know" (Part 2) Reading Summary

"The JavaScript You Don't Know" (Part 2) Reading Summary

This book is a basic book and will have a lot of basic knowledge, so here only the knowledge points that are not easy to notice are recorded here, not all of them, for everyone and yourself to read;

Yes, there are so few knowledge points in the second volume, so I don't recommend it to read the second volume;

The reading notes of the upper, middle and lower three books:

  1. "JavaScript You Don't Know" (Part 1) Reading Notes
  2. "The JavaScript You Don't Know" (middle) reading notes
  3. "The JavaScript You Don't Know" (Part 2) Reading Notes

Chapter 3 Code Organization

Subclass constructor

There is a limit ES6 sub-class constructor is: sub-class constructor call super()to access the following this; the specific reasons more complex, but can be attributed to initialize your instance thisis actually the parent constructor. Prior to the opposite for ES6, thisobjects are created by the sub-class constructor, then the subclass thiscall the parent class constructor context;

class Foo {
  constructor() {this.a = 1}
class Bar extends Foo {
  constructor() {
    this.b = 2//Error, this is not allowed to be called before super()
    super()//swap the position of the previous sentence
Reference: https://cloud.tencent.com/developer/article/1451718 "JavaScript You Don't Know" (Part 2) Reading Summary-Cloud + Community-Tencent Cloud