Skip to content

Instantly share code, notes, and snippets.

@dgowrie
Created February 5, 2015 05:45
Show Gist options
  • Select an option

  • Save dgowrie/e01c363f1732c043b85e to your computer and use it in GitHub Desktop.

Select an option

Save dgowrie/e01c363f1732c043b85e to your computer and use it in GitHub Desktop.
Prototypal inheritance in JavaScript as described by Douglas Crockford
Prototypal inheritance in JavaScript is described by Douglas Crockford as: you make prototype objects, and then ... make new instances. Objects are mutable in JavaScript, so we can augment the new instances, giving them new fields and methods. These can then act as prototypes for even newer objects. We don't need classes to make lots of similar objects....Objects inherit from objects. What could be more object oriented than that?
http://javascript.crockford.com/prototypal.html
@dgowrie

dgowrie commented Feb 5, 2015

Copy link
Copy Markdown
Author

@dgowrie

dgowrie commented Feb 5, 2015

Copy link
Copy Markdown
Author

DIFFERENT but related:

Advantages to using the "new" keyword for prototypal inheritance AKA "classical model" AKA "constructor pattern" VERSUS the "prototypal pattern" via Object.create:

  • the "new" keyword / constructor pattern is simply more widely recognized
  • "new" keyword / constructor pattern provides instanceof support whereas such support has to be hacked in with prototypal pattern via Object.create()

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