SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru phantom007's Avatar
    Join Date
    May 2008
    3 Post(s)
    0 Thread(s)

    Question Does JavaScript Support OOPs?

    I have heard from many and have read a lot that JS does not support OOPs. Then how come mootools claim that their framework supports Object-Oriented JavaScript ?

    Someone Pls throw some light on this.

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    19 Post(s)
    1 Thread(s)
    JavaScript definitely supports OOP.

    Here are a couple guides to get you started:

    And a video that's a bit advanced but it can help you understand what's happening under the hood:

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Christchurch, New Zealand
    104 Post(s)
    4 Thread(s)
    Quote Originally Posted by cancer10 View Post
    I have heard from many and have read a lot that JS does not support OOPs.
    You're been hearing wrong then. JavaScript uses prototypal inheritance, which is capable of simulating class-based objects that other languages use.
    Most other languages though are not capable of doing the prototypal inheritance that JavaScript has.

    For example, with JavaScript you can simulate private members and classical inheritance and if you want to make use of design patterns, those are fully capable too.

    This Function the Ultimate video provides very good info on what JavaScript functions can be used for, and this Programming Style and Your Brain video is a good treatment of programming style and why some ways of coding are more suitable in JavaScript than those used in other languages.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Sydney, NSW, Australia
    25 Post(s)
    1 Thread(s)
    Another book you might consider is Pakt Publishing's "Object Oriented JavaScript" by Stoyan Stefanov - the book covers everything from simulating class based inheritance through to prototypal inheritance.
    Stephen J Chapman, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Posting Permissions

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