I see the below code inside GoogleChrome/puppeteer:
this._modifiers &= ~this._modifierBit(description.key);
you can find in this file: code.
And my question is why use &=
, and how it works?
I see the below code inside GoogleChrome/puppeteer:
this._modifiers &= ~this._modifierBit(description.key);
you can find in this file: code.
And my question is why use &=
, and how it works?
this._modifiers &= ~this._modifierBit(description.key);
is a short hand of
this._modifiers = this._modifiers & ~this._modifierBit(description.key);
It depends on the coding style you opt to chose as both of them have same complexity based on computation. That is just a shorthand feature supported by the programming language. Some more examples are:
a += 10 equivalent to a = a+10
a *= 10 equivalent to a = a*10