1

In some JavaScript code, I saw

function fn() { console.log("yes") }
(0, fn)();

the fn was something else but I just make a simple one here in this question. What does the 2 lines above mean -- that is, why do we do something like (0, fn)(); ?

nonopolarity
  • 146,324
  • 131
  • 460
  • 740
  • It does seem to be the same question, but since there isn't really a very good answer on that one, I vote this question does NOT get closed and hopefully some brilliant js programmer will explain if the 0 actually performs any real function here rather than just unnecessarily bloating the code. I mean, this is a completely legitimate (and good) question. – Octopus Jul 07 '17 at 18:35
  • Short answer is the second line is exactly the same as `fn();`, but there must be a valid reason to do this. Old browsers benefit from this somehow or something along those lines... ? – Octopus Jul 07 '17 at 18:36

0 Answers0