0

I'm trying to understand the output of a webpack bundle. Everything looks understandable except the following snippet. I know the ()() pattern but I would like to know why they put a 0 as first parameter.

(0, _jquery2.default)('<li></li>').text('foo').appendTo(ul);

Doing tests I see that no matter how many params you pass it always will return the last param. so if I do

(0, 'foo', function(arg){console.log(arg)})('bar')
-> bar

It will return bar.

Why they do this way? Maybe strict mode has to do with this?

asumaran
  • 977
  • 1
  • 8
  • 16
  • So far I found something similar on wikipedia: "In contexts where an expression is expected, wrapping in parentheses is not necessary:" `0, function () { … }();` – asumaran Jun 13 '16 at 07:49
  • thank you @slindberg that's exactly what I wanted to know. – asumaran Jul 20 '16 at 21:25

0 Answers0