SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    class vs. method in JavaScript

    what are the characteristics that indicate that this Function is a class, and same thing for methods?
    for example if an object was created from a function using new keyword this indicate that this function is a class.
    Code:
    function foo()
    {}
    
    var x = new foo();
    am looking for other indicators/characteristics of class and a method.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by widd View Post
    what are the characteristics that indicate that this Function is a class, and same thing for methods?
    for example if an object was created from a function using new keyword this indicate that this function is a class.
    Code:
    function foo()
    {}
    
    var x = new foo();
    am looking for other indicators/characteristics of class and a method.
    JavaScript doesn't use the class/method techniques that lower languages have. Instead, prototyping and closure can be used to simulate those aspects.

    You'll get a pretty good run-down of the techniques at this [url="http://javascript.crockford.com/private.html"]private members[url] page.

    Just because those aspects can be simulated though, doesn't mean that they are the best way in JavaScript to achieve the end result.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •