I was wondering, what is the diferrence between a prototyped and a non-prototyped method in JavaScript? Any help is deeply appreciated.
I was wondering, what is the diferrence between a prototyped and a non-prototyped method
Share
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.
A non-prototyped method will take up memory in every instance of the class.
It will also (assuming it’s declared in the scope of the class constructor) have access to any other private variables (or methods) declared in that scope.
For example, this will create an instance of the function per object, and that function can access
myVar:and in this case there’s only one instance of the function shared between every instance of the object, but it will not have access to
myVar: