Created
May 21, 2015 03:10
-
-
Save sanketmaru/36daf333d5b80924727b to your computer and use it in GitHub Desktop.
Methods Constructor functionvs vs prototypes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Below is the jsperf test which creates instances when methods are defined inside constructor methods vs in prototype object. | |
Methods defined in prototype object is faster as each instance shares the same prototype object thats with the constructor function. | |
http://jsperf.com/prototype-vs-constructor-methods |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment