Blog Archives

JavaScript – A Different Beast, Part-7: Inheritance without Classes

Previous topic in this series: Objects without Classes

This is the seventh part of my tutorial on JavaScript. Focus of this series is to introduce developers who are comfortable with other programming languages like Java or C to the idiosyncrasies of JavaScript. Basic JavaScript knowledge is assumed, but is not necessary as the code samples are simple and self-explanatory. If you are new to JavaScript, I would suggest going through the topics below in the order given.

Topics:

  1. A different beast
  2. Types and Type Conversion
  3. Functions
  4. Scopes and Scope Chain
  5. Closures
  6. Objects without Classes
  7. Inheritance without Classes (You are here)
  8. Arrays, Maps and the for..in loop
  9. Literals and JSON
  10. Meta-Programming, Exceptions and Module Pattern

JavaScript employs Prototypical Inheritance (also called Differential Inheritance) as opposed to classical inheritance used in classical object oriented languages like Java or C++. It operates on the principle Read the rest of this entry

JavaScript – A Different Beast, Part-6: Objects without Classes

Previous topic in this series: Closures

This is the sixth part of my tutorial on JavaScript. Focus of this series is to introduce developers who are comfortable with other programming languages like Java or C to the idiosyncrasies of JavaScript. Basic JavaScript knowledge is assumed, but is not necessary as the code samples are simple and self-explanatory. If you are new to JavaScript, I would suggest going through the previous topics in order.

Topics:

  1. A different beast
  2. Types and Type Conversion
  3. Functions
  4. Scopes and Scope Chain
  5. Closures
  6. Objects without Classes (You are here)
  7. Inheritance without Classes
  8. Arrays, Maps and the for..each loop
  9. Literals and JSON
  10. Dynamic Programming, Exceptions and Module Pattern

Objects

JavaScript is object-oriented in its own sweet way. It sure has objects that encapsulate data and behavior, but decided to do without even the idea of classes! Read the rest of this entry