为什么会有人使用!!用javascript?
当我试图理解vue.js Watcher时,我看到了以下语法为什么会有人使用!!用javascript?,javascript,ecmascript-6,Javascript,Ecmascript 6,当我试图理解vue.js Watcher时,我看到了以下语法!!选项。深我完全理解的含义意味着,但是为什么有人想使用!!true因为它会再次为您提供true 谢谢如果变量是布尔值,那么不会产生任何效果,但如果变量是数字或其他类型,则会将其转换为布尔值 // options if (options) { this.deep = !!options.deep this.user = !!options.user this.lazy = !!options.lazy this.sync
!!选项。深
我完全理解的含义代码>意味着,但是为什么有人想使用!!true
因为它会再次为您提供true
谢谢如果变量是布尔值,那么
不会产生任何效果,但如果变量是数字或其他类型,则会将其转换为布尔值
// options
if (options) {
this.deep = !!options.deep
this.user = !!options.user
this.lazy = !!options.lazy
this.sync = !!options.sync
} else {
this.deep = this.user = this.lazy = this.sync = false
}
如果变量是布尔值,则
不会产生任何效果,但如果变量是数字或其他类型,则会将其转换为布尔值
// options
if (options) {
this.deep = !!options.deep
this.user = !!options.user
this.lazy = !!options.lazy
this.sync = !!options.sync
} else {
this.deep = this.user = this.lazy = this.sync = false
}
是在JavaScript中对布尔值进行强制的一种尝试。使用布尔(值)
也会得到相同的结果
是在JavaScript中对布尔值进行强制的一种尝试。对于布尔值(值)
是,也会得到相同的结果!!真的
是真的
,但是也是真的!!1
和!!“你好,世界”
。是的!!真的
是真的,但是也是真的!!1
和!!“你好,世界”
。