Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is okay for function name() and prototype.name to have the same name

Is okay for a global & prototype function name to have the same function name.

function doThis(){}

&

el.prototype.doThis = function (){}

Can these two be used together in the same script?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I tried it and they both worked correctly, but I need to know if it’s safe to use them together.

>Solution :

Yes you can. They are stored in different scopes

function doThis(){}

Is in your global script scrope. // doThis();

el.prototype.doThis = function (){}

Is only accessable with the specified object el // el.doThis();

I would prefer to name them differently to avoid misunderstandings.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading