【发布时间】:2018-08-17 03:50:59
【问题描述】:
我的变量一直评估为真并进入 IF 块。这怎么可能?即使在我将其指定为 false 之后。
this.model.hasQ1 = false
console.log('type ', typeof this.model.hasQ1) //don't know why typeof is a string
//const test = this.model.hasQ1 === 'true' //this will error out, but shouldn't if the top is typeof is a string
if(this.model.hasQ1){ //this should be false
console.log('hasQ1 ', this.model.hasQ1) //this gets printed anyways
}
//output: hasQ1 false
【问题讨论】:
-
hasQ1 是如何定义的?例如,它可以是将布尔值转换为字符串的设置器。
标签: node.js typescript