0

I am looking at some old code and some of the functions are defined as option 1 and others as option 2.

Is there a difference between these function declarations:

Option 1

obj.util.test = function util$test(x){  
... 
}

Option 2

obj.util.test = function (x){
...
}
m7913d
  • 9,476
  • 7
  • 25
  • 50
Valter
  • 2,699
  • 5
  • 27
  • 49
  • If you got many different `test` functions, identifying the `util$test` function among them might help in debugging. Apart from that, there's hardly any difference. – Bergi May 31 '17 at 19:12

1 Answers1

0

In this case they are both identical.

  • In Options 1 property test is created using a named function.

  • In Options 2 property test is created using a anonymous function.

Named functions are useful because can be seen in stack traces and call stacks.

GibboK
  • 68,054
  • 134
  • 405
  • 638