DEV Community

Discussion on: The vanilla Javascript basics to know before learning React JS

Collapse
 
tracycss profile image
Jane Tracy 👩🏽‍💻

Great input, I will take a look at the links.

Collapse
 
peerreynders profile image
peerreynders • Edited

Good coverage for three months 👍

Edit:
Method vs "arrow function on public class field" weirdness:

class A {
  myArrow = () => {
    console.log('A.myArrow()');
  }

  myMethod() {
    console.log('A.myMethod()');
  }
}

class B extends A {
  myArrow = () => {
    super.myArrow(); // arrow function exists on 
                     // public class field of A but
                     // but is not available on 
                     // the prototype chain via `super`
    console.log('B.myArrow()');
  }

  myMix() {
    super.myArrow(); // same problem
    console.log('B.myMix()');
  }

  myMethod() {
    super.myMethod(); // just works
    console.log('B.myMethod()');
  }
} 

let myB = new B();

myB.myMethod(); // 'A.myMethod()'
                // 'B.myMethod()'
myB.myMix();    // Uncaught TypeError: (intermediate value).myArrow is not a function at B.myMix
myB.myArrow();  // Uncaught TypeError: (intermediate value).myArrow is not a function at B.myArrow
Thread Thread
 
tracycss profile image
Jane Tracy 👩🏽‍💻

Awesome, explanation. 🙂🌟