パーミッション配列の割り当て

8875 ワード


  
  
  
  
var user = 0 ; //
 
var job1 = 1 ;
 
var job2 = 2 ;
 
var job3 = 4 ;
 
var job4 = 8 ;
 
// |
user = user | job1 ; // job1
console . log ( user );
 
user = user | job2 ; // job2
console . log ( user );
 
user = user | job4 ; // job4
console . log ( user );
 
 
// 0 0
console . log ( user & job1 ); // job1 -->1
 
console . log ( user & job2 ); // job2 -->2
 
console . log ( user & job3 ); // job3 -->0
 
console . log ( user & job4 ); // job4 -->8