-1

I have a condition in reactjs that starts with

+this.state.isCompleted

Why do we write + ?

vikas95prasad
  • 1,069
  • 1
  • 9
  • 27

1 Answers1

1

Is a forced conversion to number

const str = '1'
const bool = false
const fail = 'isNan?'

const num = +str
const numBool = +bool
const numFail = +fail

console.log(typeof num, typeof numBool, numFail)
Dupocas
  • 18,570
  • 6
  • 30
  • 49