Tuesday, April 22, 2014

Object Oriented Programing in JavaScript





JavaScript is a object oriented language. But does not work exactly same as other OO languages such as java or C++. 'Class' is a reserved keyword in JavaScript but it is not implemented.

Then how can we write object oriented code in JavaScript? What about inheritance as all?

JavaScript functions and objects can be used in many different ways and also JavaScript also supports something called prototypal inheritance. This allows you to write code that behaves like a class. The presentation here introduces this concept.

If you still want to write code the way you are more familiar i.e. defining a class using 'class' keyword and extending the class using 'extend', you can use CoffeeScript. I also have slides to help you move faster with CoffeeScript.




No comments:

Post a Comment