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
  • 9,449
  • 27
  • 101
  • 206

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
  • 16,911
  • 15
  • 76
  • 112