Javascript

Javascript and Prototype Design Pattern

Is Javascript's prototypal inheritance borrowed from prototype design pattern?

Guowei Lv

1 minute read

Javascript has prototypal inheritance. For example let’s create a constructor function: function Person(firstname, lastname) { this.firstname = firstname; this.lastname = lastname; } Person.prototype = { fullname: function() { return this.firstname + ' ' + this.lastname; } }; var bob = new Person("Bob", "Doe"); console.log(bob.fullname()); This is very similar to the Prototype Pattern. Whenever we want a new object, we always create it out of some prototype object. I find that it is easier to understand the JS’s prototype inheritance when comparing it with the Prototype Pattern.

Javascript the Weird Parts Distilled

Learn Javascript the Weird Parts

Guowei Lv

1 minute read

Javascript: Understanding the Weird Parts is a great course. Highly recommended if you are getting into JS from other programming languages. Much better than the book Javascript: the Good Parts in my opinion. Here I distilled all the source code with comments from the videos, for the impatients.