Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2010
    Location
    Auckland, New Zealand
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JavaScript | prototypal inheritance vs. classical inheritance

    What are the benefits of prototypal inheritance over classical inheritance?

  • #2
    New to the CF scene
    Join Date
    Sep 2010
    Location
    Bangalore
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    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

  • #4
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,376
    Thanks
    11
    Thanked 592 Times in 572 Posts
    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 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •