www.webdeveloper.com
Results 1 to 2 of 2

Thread: prototype problem

Hybrid View

  1. #1
    Join Date
    Dec 2012
    Posts
    1

    prototype problem

    function ABC(){ ... }

    ABC.prototype.newMethod = function(){} //to create a new method

    Then how about ABC.prototype = function() { ... } ?

    Can I know what is the difference?

  2. #2
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,755
    This is correct:

    ABC.prototype.newMethod = function(){} //to create a new method

    This is incorrect:

    ABC.prototype = function() { ... }

    What you may be looking for is:
    Code:
    ABC.prototype = {
      newMethod: function() {},
      anotherMethod: function() {}
    };

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles