Site Moved

This site has been moved to a new location - Bin-Blog. All new post will appear at the new location.


Object Oriented Programing(OOP) in JavaScript

A quick link dump on JavaScript inheritance and other OOP techniques that are almost never used when coding in JavaScript.

Classical Inheritance in JavaScript
JavaScript is a class-free, object-oriented language, and as such, it uses prototypal inheritance instead of classical inheritance. This can be puzzling to programmers trained in conventional object-oriented languages like C++ and Java. JavaScript's prototypal inheritance has more expressive power than classical inheritance. By Douglas Crockford
Private Members in JavaScript
Some believe that javascript lacks the property of information hiding because objects cannot have private instance variables and methods. But this is a misunderstanding. JavaScript objects can have private members. Here's how. Again, by Douglas Crockford
How to achieve private, public, and privileged members in JavaScript
One core thing about JavaScript that tends to confuse people is how to get private, public, and privileged members. First off one might even question the fact of whether or not they’re useful or needed - and to one degree, they’re not. But like any OOP language that allows for declaration of private and public members, there’s not even a need for them there as well. By Dustin Diaz
Namespacing your JavaScript
Perhaps a very uncommon approach to developing web applications that require JavaScript (but should be more common) is namespacing your scripts. This can be done very simple-like in a manner that is painless and nice-looking. By Dustin Diaz
Private Static Members in Javascript
It was a widely held belief that javascript objects could not have private instance members, that all javascript object properties where public and could be accessed and changed with external code.
OOP in JS, Part 1 - Public/Private Variables and Methods
This page shows how to create private variables and methods in classes in Javascript through the rather simple example of a person.
OOP in JS, Part 2 : Inheritance
This section discusses inheritance in Javascript.
Object Hierarchy and Inheritance in JavaScript
JavaScript is an object-oriented language based on prototypes, rather than, as is common, being class-based. Because of this different basis, it can be less apparent how JavaScript allows you to create hierarchies of objects and to have inheritance of properties and their values. This paper attempts to clarify the situation.
Object-oriented JavaScript
JavaScript is not generally considered a robust programming language, especially when compared to languages such as Java or C#: it is interpreted, rather than compiled; it is dynamically, rather than statically, typed; and it is commonly considered a procedural, rather than an object-oriented, language.
JavaScript Object-Oriented Programming
It may be shocking news, but JavaScript is a very powerful object-based (or prototype-based, whatever you wish to call it) language. Yes, JavaScript is a powerful language, not just something that's handy for image rollovers and other corny, flashy effects. However, very few people who have used JavaScript realize its capabilities. If you're one of these people, this tutorial is aimed at you.
JavaScript and Object Oriented Programming (OOP)
JavaScript is an excellent language to write object oriented web applications. It can support OOP because it supports inheritance through prototyping as well as properties and methods. Many developers cast off JS as a suitable OOP language because they are so used to the class style of C# and Java. Many people don't realize that JavaScript supports inheritance.
Introducing the best Javascript Inheritance Technique
Every programmer who's tried to apply classical Object Oriented techniques when developing with JavaScript, has at one time or another asked themselves the question: How do you call or invoke a super class method?

1 Comment:

Anonymous said...

Hi Binny,
Just found your article. About "Namespacing your JavaScript" have you heard about Ajile? Its a JavaScript library that makes namespacing Javascript really easy.