On Prototypal Inheritance, Part 2

NFJS, the Magazine - May 2012

In the first installment of this series, we discussed objects and functions in JavaScript. In this second, and final, installment in this series, we will go a bit further and see how functions are used as “instance factories” or constructors to create objects. We will see how we can use these “constructors” to not only instantiate new instances, but also endow new objects with a predefined set of properties applicable to that “class” of objects (much like Java classes). Finally, we will put it all together to build our own hierarchy. We will also see some potential potholes and how to avoid them in your code.

An online version of this article is not available. This article is available in PDF, MOBI, and EPUB to those who have subscribed.

About Raju Gandhi

Raju Gandhi

CTO Integrallis Software & Technophile

Raju Gandhi is a Java/Ruby/Clojure developer and a programming language geek. He has been writing software for well over a decade in several industries including education, finance, construction, manufacturing and retail sectors. Raju has a graduate degree in Industrial Engineering from Ohio University. In his spare time you will find Raju reading, or watching movies, or playing with yet another programming language. He is affectionately known as looselytyped on Twitter.

NFJS, the Magazine - May 2012

NFJS the Magazine - May 2012

In this Issue: