I have some confusion regarding function invokes in javascript. there would be multiple ways to invoke a function on different contexts. Normally I have seen these 2 ways to invoke a function.
Method 1:
$scope.test = function(){
alert("function invoked");
}();
Method 2:
$scope.test = function(){
alert("function invoked");
}
$scope.test();
However, I would like to know:
There is any difference in the following code with respect to performance?
Other criteria and in what context should I choose these?
I've gone through few of the blogs but couldn't understand it properly.