Or Equal Operator

# Артем Гуржий (24 days ago)

I was thinking, is there a proposal for or equal operator as in ruby, or is there any sense for doing so? Example:

let a = 1;
let b = 0;
a ||= b;

Would be interpreted as

a = a || b;

PS: Ruby version is

a || a = b;

They are both equal, but for me, it doesn't look like the javascript version of doing this.

# Claude Pache (24 days ago)

Le 4 févr. 2017 à 02:12, Артем Гуржий <artem.gurzhii at gmail.com> a écrit :

Hi, I was thinking, is there a proposal for or equal operator as in ruby, or is there any sense for doing so? Example:

let a = 1;
let b = 0;
a ||= b;

Would be interpreted as

a = a || b;

PS: Ruby version is

a || a = b;

They are both equal, but it doesn't look like the javascript version of doing this.

Older discussions on the topic:

esdiscuss.org/topic/proposing-a-conditional-assignment-or-equals-operator
esdiscuss.org/topic/new-assignment-operators-not-bit-wise-or
esdiscuss.org/topic/please-add-orequal-operator
esdiscuss.org/topic/is-much-needed
esdiscuss.org/topic/operators-and
esdiscuss.org/topic/logical-assignment-operators

—Claude

# Артем Гуржий (24 days ago)

Is there proposal for this?

# kdex (24 days ago)

Not that I know of.

I think It also went down as the "mallet operator" and got supported by babel at some point.