Any difference between those two in Javascript? -


using this

var class1 = function() {                this.test1 = function() {         };     }; 

and following

function class1() {  };  class1.prototype.test1 = function() {  }; 

is there difference between two?

the first 1 makes separate copy of function each class instance.
allows function use closure'd variables constructor.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -