<pedrocorreia.net ⁄>
 

<JavaScript Inheritance via Prototypes and Closures ⁄ >




clicks: 845 845 2008-12-13 2008-12-13 goto programacao myNews programacao  Bookmark This Bookmark This


JavaScript as a prototypical language offers loads of solutions to implement classes and class inheritance. When coming from an Object Oriented language such as Java or Ruby, these solutions aren't obvious at the first glance.

I started coding JavaScript years ago and always found a solution for my specific case. But things felt messy and I always thought "Is this really the right way of doing it?". Well, after all those years, experience took away this feeling and now I want to share some stuff that finally meant a break-through of understanding for me.

There are two different concepts of doing inheritance in JavaScript. One is using the prototype property of a function as a mean to create something similar to a "class". The other concept is using the constructor function itself to create a class dynamically during runtime.

For both concepts I'll show you their basic idea and compact helpers for creating inheritance in an elegant way.

Let's start with the prototype-based concept.



este é só um excerto do artigo, para aceder ao artigo completo, clique no link em baixo:
this is just a small excerpt from the article, to access the full article please click in the link below:

http://www.ruzee.com/blog/2008/12/javascript-inheritance-via-prototype...




Subscribe News RSS  Subscribe News Updates by E-mail





myNews <myNews show="rand" cat="programacao" ⁄>

RouterJs: easy routing for your ajax Web applications

RouterJs is a simple router for your ajax web apps. It's build upon History.js which means that Rout (...)

clicks: 100 100 2012-05-14 2012-05-14 goto url (new window) haithembelhaj.g... goto myNews programacao


Backbone computed properties

This gist shows one way to implement read- and write-enabled computed properties on a Backbone Model (...)

clicks: 114 114 2012-05-13 2012-05-13 goto url (new window) https://gist.gi... goto myNews programacao


Create Instagram Filters With PHP

In this tutorial, I'll demonstrate how to create vintage (just like Instagram does) photos with PHP (...)

clicks: 110 110 2012-05-12 2012-05-12 goto url (new window) net.tutsplus.co... goto myNews programacao


HTML5 jQuery Paint Plugin

Websanova Paint is a HTML5 canvas based jQuery plugin. It allows you to free paint on a canvas area (...)

clicks: 103 103 2012-05-12 2012-05-12 goto url (new window) websanova.com/t... goto myNews programacao


Android Query

Android-Query (AQuery) is a light-weight library for doing asynchronous tasks and manipulating UI el (...)

clicks: 111 111 2012-05-12 2012-05-12 goto url (new window) code.google.com... goto myNews programacao


Real-time Applications With Node.js and Socket.IO

Hey everyone! Sorry about the long pause since the last blog post, life has been quite hectic for th (...)

clicks: 113 113 2012-05-11 2012-05-11 goto url (new window) codingcookies.c... goto myNews programacao


Sass vs. LESS vs. Stylus: Preprocessor Shootout

CSS3 preprocessors are languages written for the sole purpose of adding cool, inventive features to (...)

clicks: 117 117 2012-05-11 2012-05-11 goto url (new window) net.tutsplus.co... goto myNews programacao


15 Handpicked jQuery Drop Down Menus Tutorials

Here we are presenting another brilliant collection of 15 jQuery navigation menu that you can downlo (...)

clicks: 125 125 2012-05-10 2012-05-10 goto url (new window) smashingapps.co... goto myNews programacao