Normally you'll see code like:
let x = !!y;
Where this is casting whatever value y
has into a simple true
or false
outcome, a boolean. This is often employed to avoid retaining references to things you don't need, like y
could be a complex structure but you don't care about the details, you just want to track if it was assigned.
It's unusual to see this employed in an if
since it really doesn't do anything useful. It converts to a boolean, but if
will anyway. This is just junk code.
It might as well be if (!!!!!!!!!!!!!!!!!!!!x)
for all the good it does.
A better version would look like:
if (this._currentItemIndex) {
// Some non-zero value was assigned
}
Or if it is populated:
if (this._currentItemIndex > 0) {
// Communicates intent better
}