-1

I have a condition in reactjs that starts with

+this.state.isCompleted

Why do we write + ?

vikas95prasad
  • 1,234
  • 1
  • 12
  • 37

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
  • 20,285
  • 6
  • 38
  • 56