我有这个 !!花药对象的标记并且它有效,但在这里它不起作用(在一种情况下,在其他情况下有效)。
if (!!slides) {
console.log("close view clear slides")
clearInterval(slides);
}
在萤火虫我得到这个错误:
ReferenceError: slides is not defined
我的条件应该是什么?
我有这个 !!花药对象的标记并且它有效,但在这里它不起作用(在一种情况下,在其他情况下有效)。
if (!!slides) {
console.log("close view clear slides")
clearInterval(slides);
}
在萤火虫我得到这个错误:
ReferenceError: slides is not defined
我的条件应该是什么?
如果未定义变量,则不能使用它。
typeof(asdf)
"undefined"
!asdf
ReferenceError: asdf is not defined
if (typeof(asdf) != "undefined") {
// will only execute if asfd is defined.
}
改变
if (!!slides) {
到
if (!slides) {
但是,如果 slides 是 false、null 或 undefined,那么清除它不会做任何事情。所以,也许你的意思是
if (slides) {
?