Important Notice:

Bitwise Operators

Bitwise Operators

17 views 1 min read

7. बिटवाइज ऑपरेटर (Bitwise Operators)

बाइनरी लेवल (bits) पर काम करते हैं। कम इस्तेमाल होते हैं, लेकिन सूची में हैं।

Example:-

console.log(5 & 1);   // AND → 1
console.log(5 | 1);   // OR  → 5
console.log(5 ^ 1);   // XOR → 4
console.log(~5);      // NOT → -6
console.log(5 << 1);  // Left shift → 10
console.log(5 >> 1);  // Right shift → 2
console.log(5 >>> 1); // Zero-fill right shift → 2

7. Bitwise Operators
Work at the binary (bit) level. Less commonly used.

Example:

text

console.log(5 & 1); // AND → 1 console.log(5 | 1); // OR → 5 console.log(5 ^ 1); // XOR → 4 console.log(~5); // NOT → -6 console.log(5 << 1); // Left shift → 10 console.log(5 >> 1); // Right shift → 2 console.log(5 >>> 1); // Zero-fill right shift → 2

Related Notes