-1

I have a condition in reactjs that starts with

+this.state.isCompleted

Why do we write + ?

vikas95prasad
  • 774
  • 1
  • 5
  • 20

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
  • 15,944
  • 5
  • 23
  • 43