Javascript factory functions

by Arnold Burian

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

class Dog {
  constructor() {
    this.sound = 'woof'
  talk() {
const sniffles = new Dog(); // 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.

You may also like

This website uses cookies to improve your experience. Accept Read More