const READ = 0b1; const CREATE = 0b10; const UPDATE = 0b100; const DELETE = 0b1000; const rights = READ | UPDATE | DELETE //組合許可權讀 更新 刪除 13 console.log(rights) //13 if ((rights && READ) === 1) { console.log('有read許可權') } else { console.log('沒有read許可權') } if ((rights ^ READ) === 0b1100) { console.log('刪除read許可權') } else { console.log('有read許可權') }