Skip to content

Instantly share code, notes, and snippets.

@nikkaroraa
Last active June 19, 2018 11:42
Show Gist options
  • Save nikkaroraa/60b55052010a82e74cdcb97ce48129e8 to your computer and use it in GitHub Desktop.
Save nikkaroraa/60b55052010a82e74cdcb97ce48129e8 to your computer and use it in GitHub Desktop.
Things to clear up before jumping into the world of React

1. Clearing the confusion between prototype, proto and [[Prototype]]

prototype

  function Dog(name) {
    this.name = name; 
    this.speak = function() {
        return this.name + " says woof";
    }
  }

  console.log(Dog.prototype);

  // The Output
  {
    constructor: Dog(name) {
      this.name = name;
      this.speak = function() {
          return this.name+" says woof";
      }
    },
    __proto__: Object { ... }
  }

I have found 2 blog posts that make the topic extremely clear.

Here are the 2 links:

  1. __proto__ vs prototype

  2. [[Prototype]]

If you still have any doubts, read the following blog and hopefully all your doubts will get resolved:

Object Oriented JavaScript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment