Skip to content
This repository was archived by the owner on Jul 22, 2020. It is now read-only.

Is assigned expression always evaluated even if not needed? #28

Closed
yukulele opened this issue May 6, 2020 · 3 comments
Closed

Is assigned expression always evaluated even if not needed? #28

yukulele opened this issue May 6, 2020 · 3 comments
Labels
question Further information is requested

Comments

@yukulele
Copy link

yukulele commented May 6, 2020

in this example:

let a = 0;
let b = true;
b = b || a++;
console.log(a); // 0

a++ is not evaluated.

in this case:

let a = 0;
let b = true;
b ||= a++;
console.log(a); // ?

should a++ be executed?

@ljharb
Copy link
Member

ljharb commented May 6, 2020

No, see #3 (comment)

@jridgewell
Copy link
Member

No, a will be 0.

@jridgewell jridgewell added the question Further information is requested label May 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants