Notes for You:: Bitwise Operators in JavaScript - JavaScript Tutorial 29
are used to perform operations on bits (i.e. 0s and 1s)
convert the given decimal number(s) to their binary equivalent number, and then they perform the operations on bits of the converted binary equivalent number(s) and return the result as decimal number.
& (Bitwise AND Operator):
If both LHS and RHS are 1 then the result will be 1, in all other cases result will be 0.
| (Bitwise OR Operator):
If both LHS and RHS are 0 then the result will be 0, in all other cases result will be 1.
^ (Bitwise Exclusive OR Operator):
If both LHS and RHS are same then the result will be 0, otherwise the result will be 1.
~ (Bitwise complement Operator):
If the given operand is positive integer, then add 1 and change the sign.
If the given operand is negative integer, then subtract 1 and change the sign.
<< (Bitwise Left Shift Operator):
Shifts the bits of first number to the left by number of positions indicated by second number.
firstNumber * pow(2, secondNumber).
>> (Bitwise Right Shift Operator):
Shifts the bits of first number to the right by number of positions indicates by second number.
firstNumber / pow(2, secondNumber).
Example Code:
document.write("Bitwise Operators");
document.write(1 & 1); // 1
document.write(0 | 0); // 0
document.write(1 ^ 0); // 1
document.write(2 & 5); // 0
document.write(2 | 5); // 7
document.write(2 ^ 2); // 0
document.write(~5); // -6
document.write(~(-3)); // 2
document.write(1<<4); // 16
document.write(64>>2); // 16
Note:
replace < with less-than symbol.
replace > with greater-than symbol.
=========================================
Follow the link for next video:
JavaScript Tutorial 30 - Special Operators in JavaScript | JavaScript Special Operators
• Special Operators in JavaScript - Jav...
Follow the link for previous video:
JavaScript Tutorial 28 - Binary Number System Versus Decimal Number System
• Binary Vs. Decimal Number System - Ja...
=========================================
JavaScript Tutorials Playlist:-
• JavaScript Tutorials
=========================================
Watch My Other Useful Tutorials:-
jQuery Tutorials Playlist:-
• jQuery Tutorials
jQuery UI Tutorials Playlist:-
• jQuery UI Tutorials
Bootstrap Tutorials Playlist:-
• Bootstrap4 Tutorials
=========================================
► Subscribe to our YouTube channel:
/ chidrestechtutorials
► Visit our Website:
https://www.chidrestechtutorials.com
=========================================
Hash Tags:-
#ChidresTechTutorials #JavaScript #JavaScriptTutorial
In questa pagina del sito puoi guardare il video online Bitwise Operators in JavaScript - JavaScript Tutorial 29 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato ChidresTechTutorials 25 febbraio 2017, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 9,495 volte e gli è piaciuto 210 spettatori. Buona visione!