Jump to content

How Object Oriented Javascript works?

- - - - -

  • Please log in to reply
4 replies to this topic

#1
tejasgosai

tejasgosai

    Newbie

  • Members
  • Pip
  • 2 posts
hi, i have read some files on object oriented js... i have one question if there is no class then how all object works? it was written that it is prototype based oop concept which i didnt quite understand... can anyone explain me.....

#2
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
Objects in javascript are declared as functions. These "object" functions can then be instantiated with the 'new' operator.

Example:

function myobject(parameter) {

this.x = parameter;

}


var foo = new myobject(5);


document.write(foo.x); // writes '5'


Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#3
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP
I just found this article interesting:
Object-Oriented Javascript - Nefarious Designs

It seems javascript can handle all the important aspects of an OO language.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Technically, JavaScript is a prototype language, which means you create objects from other objects, then add methods to them as needed.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
tejasgosai

tejasgosai

    Newbie

  • Members
  • Pip
  • 2 posts
thanks to every one..... i have reading a lot of stuff on this topic...n also started some practical work on it.... i got the basic fundamentals about OOJS....




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users