Results 1 to 6 of 6

Thread: Is JavaScript an OOP?

  1. #1
    Join Date
    Apr 2008
    Posts
    38
    Thanks
    9
    Thanked 1 Time in 1 Post

    Question Is JavaScript an OOP?

    For those of your unfamiliar, OOP is Object Oriented Programming. There has been a long debate on whether JavaScript is one.
    I would like to have a debate in this thread about it. In my personal opinion, JavaScript IS an OOP because it is impossible to use it without objects.

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Java is an OOP, but Javascript is not by default. It is possible to create and use Javascript Objects.

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    If I can, by choice, speak Russian, does that mean that I am Russian?

    I think that basically summarizes the argument.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Dec 2007
    Location
    Ankara, Turkey
    Posts
    160
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default

    It has strong OOP abilities with prototype support. Don't you think it is Russian, djr33?

  5. #5
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    JS has OO support. It just doesn't have classes, but classes are not requirements for OOP anyway.

    Looking at wikipedia's requirements for an OOPL:

    • Class: Whoever tells you this is a requirement for a language to be OO is lying. In any case, in JS, you can (and usually do) simulate classes.
    • Object: Objects exist in JS.
    • Method: In JS, a method is any function that is bound to an object when called.
    • Message Passing: Function arguments and state changes.
    • Inheritance: Prototype chain and call/apply.
    • Encapsulation: Closures can be used to encapsulate, but we generally don't bother (at least with constructor functions).
    • Abstraction: JS has all the wikipedia elements under Abstraction.
    • Polymorphism: Duck-typing.


    JS supports all of these.
    Trinithis

  6. #6
    Join Date
    Apr 2008
    Posts
    38
    Thanks
    9
    Thanked 1 Time in 1 Post

    Default

    I think DHTML, not the JavaScript itself is OOP because it is nearly impossible to do something useful with the data without objects. Alert(), the simplist task, is acually part of the window object. So is getElementById().

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
  •