// Between these two ways of creating a JS function, do they represent the
exact same thing?:
function myFn(a) {return 1;} // SAMPLE A
myFn = function(a) {return 1;} // SAMPLE B
// ... and then I assign one or the other function as a method like so:
function myObject() {
this.f = myFn;
}
// Base on the myObject, when I create new instances does it matter where
SAMPLE A or B was used above?
var o1 = new myObject();
var o2 = new myObject(); //etc...
/* For example, I might assume that using SAMPLE A results in one function
entry point being used amongst the multiple methods I created.
Would SAMPLE B end up creating copies of the function if it were used?
*/
Is there any good supporting JavaScript documentation that gets into the
nitty gritty of this question?
Thanks.
-- John
Comment