0

What does if (t == +t) { ... } mean?

Sorry for asking such a simple question, but I have searched for "plus operator" and tried to evaluate it in javascript myself, but I cannot guess what the purpose is.

Jamgreen
  • 10,329
  • 29
  • 113
  • 224

1 Answers1

0

Its a unary operator and it coerces t to a number from a string. It has the same effect as:

if (t == Number(t)) { ... }

For more information: Is plus sign in +process a typo in Node.js documentation on domains?

Community
  • 1
  • 1
agconti
  • 17,780
  • 15
  • 80
  • 114