Wednesday, August 31, 2022

Javascipt an easy to understand about assignment

 Bitwise AND assignment x &= f() _____________x = x & f()

Bitwise XOR assignment x ^= f() _____________________x = x ^ f()

Bitwise OR assignment x |= f() ______________________x = x | f()

Logical AND assignment    x &&= f()___________ x && (x = f())

Logical OR assignment x ||= f() ______________________x || (x = f())



And the differences of (x&f()) and (x&& = f()) 

And the first and this will serve all that are above and have the name bitwise, this will make an operation in the binary represetation of the number so you put 4 and will be worked like this 0000000000000010 if is 5 00000000000000011, and the XOR only is understandble for binary numbers, and isn't a logic comaprision is an operation in that cases will remain the 000 and in one case where is 1 will be replaced for 0 remaining of the same way the 0, and the other in one operands have a one will be one, and the other the both operands need be 1 to the result change, and all these have an antilogic for negatives number that in binary had a lot of ones but how I don't know work with negative binaries let be that way.

So let work with the logicals because the need of a binary is very hard to imagive but of course that have have have.

So the logicals

Logical --> AND assignment    x &&= f()

And with simple terms to be more comprehensive:

you have the x and when you put the another value after the && like this x&&=b.

If the a isn't "0" or in others cases, "empty string", "undefined" or any value that is like null the x will remain but if the x is a null value the b will replace its value.

Logical OR assignment x ||= f()

And this one is this way if the x is a valid value will be replaced for the factor of the right of the assgnment is the opposite.

Rute Bezerra de Menezes Gondim


No comments:

Post a Comment