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
  • 10,244
  • 7
  • 28
  • 56
Valter
  • 2,859
  • 5
  • 30
  • 51
  • 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
  • 71,848
  • 143
  • 435
  • 658