Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-29-2010, 07:27 AM   PM User | #1
andymoles
New to the CF scene

 
Join Date: Sep 2010
Location: Auckland, New Zealand
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
andymoles is an unknown quantity at this point
JavaScript | prototypal inheritance vs. classical inheritance

What are the benefits of prototypal inheritance over classical inheritance?
andymoles is offline   Reply With Quote
Old 12-29-2010, 07:47 AM   PM User | #2
amtindia
New to the CF scene

 
Join Date: Sep 2010
Location: Bangalore
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
amtindia is an unknown quantity at this point
In My Opinion, the major benefit of prototypal inheritance is its simplicity.

The prototypal nature of the language can confuse people who are classically trained, but it turns out that actually this is a really simple and powerful concept, differential inheritance.

You don't need to make classification, your code is smaller, less redundant, objects inherit from other, more general objects.

If you think prototypically you will soon notice that you don't need classes...

Prototypal inheritance will be much more popular in the near future, the ECMAScript 5th Edition specification introduced the Object.create method, which allows you to produce a new object instance that inherits from another one in a really simple way:

Code:
var obj = Object.create(baseInstance);
This new version of the standard is being implemented by all browser vendors, and I think we will start to see more pure prototypal inheritance...


Warm Regards,
Aby Varghese
Director at AMT
amtindia is offline   Reply With Quote
Old 12-29-2010, 11:36 AM   PM User | #3
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by andymoles View Post
What are the benefits of prototypal inheritance over classical inheritance?
why you post twice? this is confusing. Please ask one of the moderators to join this thread with http://www.codingforums.com/showthread.php?t=213444

best regards and happy holidays
oesxyl is offline   Reply With Quote
Old 12-29-2010, 07:05 PM   PM User | #4
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,553
Thanks: 9
Thanked 480 Times in 463 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
Code:
String.prototype.tag=function(a){
   return ["<",a,">",this,"</",a,">"].join("");
}

"this is a text phrase".split("").reverse(
   ).join("").toUpperCase().tag("span");

//==<span>ESARHP TXET A SI SIHT</span>
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:15.2% IE7:0.5% IE8:8.4% IE9:8.5% IE10:8.5%
rnd me is offline   Reply With Quote
Reply

Bookmarks

Tags
classical inheritance, javascript, prototypal inheritance

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:38 AM.


Advertisement
Log in to turn off these ads.