js中加一个+是什么意思?

我在 reactjs 中有一个条件,它以

+this.state.isCompleted

我们为什么要写作+


白衣非少年
浏览 148回答 1
1回答

慕森王

是强制转换为numberconst str = '1'const bool = falseconst fail = 'isNan?'const num = +strconst numBool = +boolconst numFail = +failconsole.log(typeof num, typeof numBool, numFail)
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript