is prtotype an object or a method?
I think it is a method but the book I am reading, a translation of morrison's book, said it is an object.
is prtotype an object or a method?
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: is prtotype an object or a method?
It is an object. You cannot invoke it. Methods are functions attached to an object. You can invoke them as such. Objects are just containers for data.
JavaScript's prototype object is an object that knows how to construct the object it belongs to. You can add new methods to a "class" by adding them to the prototype object for that class, among other interesting things. JavaScript's object model is a little quirky at first, but is actually very simple once you get used to it.
JavaScript's prototype object is an object that knows how to construct the object it belongs to. You can add new methods to a "class" by adding them to the prototype object for that class, among other interesting things. JavaScript's object model is a little quirky at first, but is actually very simple once you get used to it.
Re: is prtotype an object or a method?
That's a constructor, prototype is just that - an object above your current object in the prototype chain.JavaScript's prototype object is an object that knows how to construct the object it belongs to.
Re: is prtotype an object or a method?
so, are you saying a prototype is neither an object nor a method, but a constructor?Weirdan wrote:That's a constructor, prototype is just that - an object above your current object in the prototype chain.JavaScript's prototype object is an object that knows how to construct the object it belongs to.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: is prtotype an object or a method?
No, he's not saying that. The first sentence of this article describes it well:
http://en.wikipedia.org/wiki/Prototype- ... rogramming
The rest of the article should answer your questions.
http://en.wikipedia.org/wiki/Prototype- ... rogramming
The rest of the article should answer your questions.
(#10850)