-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This repository is part of a larger project!
A convenient feature of javascript is the possibility to use some specific bitwise operators with string operand(s).
The operand(s) will be automatically converted when using the following operators:
Operator | Name |
---|---|
"~" | NOT |
"^" | XOR |
"&" | AND |
"|" | OR |
"<<" | Left Shift |
">>" | Right Shift |
">>>" | Zero Fill Right Shift |
"*" | Multiplication |
On closer examination it is obvious that the last operator in the table is not a bitwise one. Nevertheless the "*" has the same abilities to handle operands as the rest.
For a better understanding here are some js examples:
"2" * "2" //result should be 4
"14" | "9" //result should be 15
Also mixing string with integer values should lead to a correct result:
"2" * 2 //result should be 4
The user interaction part should look like the content as seen below by starting "index.html" in a web browser.
There is also a helpfull describing note which can be found when starting "index.html".
The results could be displayed as shown in the picture below.
The colored areas are just for a better readability in the wiki and are not part of the content. To use the project just download the files and execute "index.html". Note that all files should be placed in the same folder so that the functionality of the code is guaranteed.
This knowledge was gained:
Effective JavaScript "68 Specific Ways to Harness the Power of JavaScript" by David Herman