What’s the difference between adding functions to an object and prototyping them onto the object?
Prototyping allows the object/model to call itself?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An “object of functions” is typically used to “namespace” a set of functions so that there is one container object with numerous methods rather than numerous global functions. The benefit is in keep code components categorised or grouped by the object (and perhaps an object hierarchy), there are no benefits to performance and if global functions are thoughtfully named, there should be no reasonable chance of a naming collision. That is, the primary purpose is to create neat, logical groups of functions.
By “prototyping methods” I presume you mean using a constructor to create instances. Constructors and prototypes are used where inheritance is required, they are quite a different strategy to “namespaceing”, the use of one does not preclude the other. It is quite reasonable to use prototypes for inheritance and use an “object of functions” to group the instances (and constructors for that matter).