0

I've been learning OOP in javascript and by taking different tutorials i understood that people where doing constructor functions using different syntax, is there a difference between these two ways? are there more ways?

first, Using the class syntax

 class Fish {
      constructor() {
        this.head = 1,
        this.eyes = 2
      }
    }

    let whale = new Fish();

Second, Using the function syntax

function Human() {
  this.head = 1,
  this.arms = 2,
  this.legs = 2,
  this.fingers = 20
}

let joe = new Human();

0 Answers0