在Javascript中做什么?=

时间:2015-07-30 07:28:42

标签: javascript

在尝试修复另一个人的代码中的错误时,我发现了这一行:

affiliationData.affiliationStatuses |= AffiliationStatuses.affiliatedWithCurrentCrmUser;

它实际上做了什么?

试图在MDN上找到它,但是searching for |= returns zero results

3 个答案:

答案 0 :(得分:4)

ActorBitwise OR运营商。

该陈述相当于:

|

答案 1 :(得分:3)

按位OR分配

速记员:

x |= y

含义:

x = x | y
  

Source

答案 2 :(得分:2)

`x |= y` 

是简写  x= x|y其中|bitwise OR

因此

affiliationData.affiliationStatuses |= AffiliationStatuses.affiliatedWithCurrentCrmUser;

相当于:

affiliationData.affiliationStatuses = affiliationData.affiliationStatuses | AffiliationStatuses.affiliatedWithCurrentCrmUser;