i have read articles that say:
using the
prototype
will be fastest since functions declared are shared. more detail was explained in this article where tapping JS native prototype will increase performance as compared to using 'improvisions'.closures should perform worse since each creation of it returns a separate copy of a set of functions and variables.
objects (functions) are sort of closures but with
this
. has access control (public/private). they're supposed to be better than closures.object literals (the one looking like JSON) act like objects but have no sense of privacy. they are comparable to static methods in JAVA. i have no article to refer, i just included this for comparison.
i was testing a simple comparison of the 4 methods using jsperf in building "Classes" before i proceed with my project and i was looking forward to prototypes winning. however, closures beat them hands down. how come? is there some give and take here? unseen bias?
i may not be new to JS, but i'm totally new to these optimization concepts, please bear with me. i'm still studying about these things.