Reputation: 15372
In this answer which tests whether or not a page has been cached, I see this variable declaration.
var isCached = currentCookie !== null;
What is the significance of the =
and !==
operators together in one statement?
Upvotes: 1
Views: 73
Reputation: 20159
That snippet is equivalent with:
var isCached = (currentCookie !== null);
In other words, isCached
is set to true
if and only if currentCookie
is strictly not equal to the null reference.
Upvotes: 2
Reputation: 123397
that expression means:
isCached
is true when currentCookie !== null
, false otherwise
you should read it like
var isCached = (currentCookie !== null)
or more verbosely is equivalent to
var isCached;
if (currentCookie !== null) {
isCached = true;
}
else {
isCached = false;
}
Upvotes: 2