1

Is there any difference between these two methods?

method 1:

(function(){
console.log('test');
}());

method 2:

(function(){
console.log('test');
})();

And why this doesn't work?

function(){
console.log('test');
}();
Navin Rauniyar
  • 10,127
  • 14
  • 45
  • 68
  • Show how you used it in your code; then only it can be justified. – Rajesh Paul Feb 07 '14 at 03:58
  • 3
    possible duplicate of [Are "(function ( ) { } ) ( )" and "(function ( ) { } ( ) )" functionally equal in JavaScript?](http://stackoverflow.com/questions/5938802/are-function-and-function-functionally-equal-i) and http://stackoverflow.com/questions/423228/difference-between-function-and-function and http://stackoverflow.com/questions/14011509/javascript-self-invoking-functions and http://stackoverflow.com/questions/7647019/what-are-the-differences-between-these-three-types-of-module-pattern – j08691 Feb 07 '14 at 03:59

0 Answers0