Parenthesis for anonymous JavaScript functions

后端 未结 3 1325
忘掉有多难
忘掉有多难 2020-12-20 23:45

Are they the same?

var multiply = function () {
      //..
      }();

var multiply1 = (function () {
      //..
      }());
相关标签:
3条回答
  • 2020-12-20 23:51

    They seem to work the same here in Chrome: http://jsfiddle.net/jfriend00/G5DZp/

    0 讨论(0)
  • 2020-12-21 00:09

    Yes, they are totally identical.

    0 讨论(0)
  • 2020-12-21 00:11

    As mquander said in that case they are the same, but if you want to read a little more about it you can go to: An Important Pair of Parens.

    0 讨论(0)
提交回复
热议问题