2

For the first time I met this method of setting a variable. I'm a little tangled up with double brackets. What does this mean?

var defaultState = (0, _state2.default)(servicePath, stateOptions);
Alexandr Lukovnikov
  • 170
  • 1
  • 5
  • 17

1 Answers1

1

(0, _state2.default) is an expression which contains comma operator. It evaluates to its last operand. Here _state2.default is last operand. So

(0, _state2.default)(servicePath, stateOptions);

Is same as

_state2.default(servicePath, stateOptions);

The second brackets call the function with two arguments.

The first () are used to group an expression. While the second () are used to call the function.

Maheer Ali
  • 35,834
  • 5
  • 42
  • 73
  • 2
    But why would we use it like this? We can call `_state2.default(servicePath, stateOptions);` directly, or `(_state2.default)(servicePath, stateOptions);` if we want to keep the brackets. – R Xy May 18 '19 at 03:24