Skip to content

Instantly share code, notes, and snippets.

@sanketmaru
Created May 21, 2015 03:10
Show Gist options
  • Save sanketmaru/36daf333d5b80924727b to your computer and use it in GitHub Desktop.
Save sanketmaru/36daf333d5b80924727b to your computer and use it in GitHub Desktop.
Methods Constructor functionvs vs prototypes
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