Y
Y
yankoyski2018-03-14 06:18:35
JavaScript
yankoyski, 2018-03-14 06:18:35

What does the unary plus do here?

Two essentially identical codes:

+function() {
  alert('Вызов на месте');
}();

(function() {
  alert('Вызов на месте');
}());

Why does the first code work? What does the unary plus do?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim, 2018-03-14
@yankoyski

Plus indicates that this is a Function Expression and not a Function Declaration. Parentheses do the same.

D
Dubrovin, 2018-03-14
@Dubrovin

In the second example, the parentheses are wrong, it should be like this:

(function() {
  alert('Вызов на месте');
})();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question