Javascript factory functions

Check out Javascript factory functions by JR. Here is an excerpt:

class Dog {
  constructor() {
    this.sound = 'woof'
  }
  talk() {
    console.log(this.sound)
  }
}
const sniffles = new Dog()
sniffles.talk(); // outputs 'woof'

Problem with the above class is that as soon as you use it somewhere else, you get a different this.

The full article is available here.