在this answer中测试一个页面是否被缓存,我看到这个变量声明。多个操作符在一个变量声明中的含义
var isCached = currentCookie !== null;
什么是=
和!==
运营商的意义集中在一个声明?
在this answer中测试一个页面是否被缓存,我看到这个变量声明。多个操作符在一个变量声明中的含义
var isCached = currentCookie !== null;
什么是=
和!==
运营商的意义集中在一个声明?
该表达的意思是:
isCached
是真实的,当currentCookie !== null
,否则为false
你应该看它像
var isCached = (currentCookie !== null)
以上冗长相当于
var isCached;
if (currentCookie !== null) {
isCached = true;
}
else {
isCached = false;
}
很酷。感谢这一点。超清晰! – 1252748
即片段是与等效:
var isCached = (currentCookie !== null);
换句话说,isCached
设为true
当且仅当currentCookie
严格不等于空引用。
感谢您的帮助! – 1252748
重要性?一个设置值(=),一个确定值(!==,严格不等式)。与其他分配操作相同,如“a = 42 + 69”。 –