SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru phantom007's Avatar
    Join Date
    May 2008
    Posts
    742
    Mentioned
    3 Post(s)
    Tagged
    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
    Posts
    1,276
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    JavaScript definitely supports OOP.

    Here are a couple guides to get you started:

    https://developer.mozilla.org/en/Int...ted_JavaScript
    http://eloquentjavascript.net/chapter8.html

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

    http://www.youtube.com/watch?v=DwYPG6vreJg

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,716
    Mentioned
    103 Post(s)
    Tagged
    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
    Location
    Sydney, NSW, Australia
    Posts
    16,834
    Mentioned
    25 Post(s)
    Tagged
    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

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

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