[Algorithm] Bitwise Operators

"|" can be used as assign

"&" can be used as check

// Read, Write, Execute
// 0100 Read
// 0010 Wirte
// 0001 Execute

const read = 4;
const write = 2;
const execute = 1;

let myPremission= 0;
myPremission = myPremission | read | write; // 6 -- 0110

let message = (myPresmission & read) ? 'yes' : 'no'; // yes
原文地址:https://www.cnblogs.com/Answer1215/p/11985015.html