I am newbie to javascript and oops. I have a javascript function
function foo(args){
...
}
//mehtod1
var type1=foo(a);
//mehtod2
var type2= new foo(a);
Now my doubt is which will give us more performance mehtod1 or method2
what is the significance of new keyword and what are the advantages over mehtod1?
(sorry if the question already exists and for my poor english)
The first call performs one operation: function evaluation. The second performs two: creates a new object and then does a function evaluation. Don’t use new to evaluate a function.
Here is an example: