其他分享
首页 > 其他分享> > [Algorithm] Bitwise Operators

[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

 

标签:Execute,const,Algorithm,read,Operators,Bitwise,write,Read,myPremission
来源: https://www.cnblogs.com/Answer1215/p/11985015.html