News for hackers. Stuff that matters.
Re:What’s New in ES2019 by ubertaco on Tuesday July 30, 2019 @10:55AM (#20565353)
I'm down if you require a let/var/const in front of it:

    if (foo = bar()) { // syntax error!
    }

    if (let foo = bar()) { // works fine
    }

    if (const foo = bar()) { // also works fine
    }

    if (var foo = bar()) { // also also works fine
    }
Re:What’s New in ES2019 by fenomas on Tuesday July 30, 2019 @11:21AM (#20565660)
> if (foo = bar()) { // syntax error!

That's already an error in strict mode (which would presumably be on for anyone writing bleeding-edge JS).

Re:What’s New in ES2019 by AgentME on Thursday August 01, 2019 @09:44PM (#20590099)
It's only an error in strict mode if there's no variable in scope named foo.
Re:What’s New in ES2019 by dotancohen on Tuesday July 30, 2019 @12:43PM (#20566592)
And what if foo had already been defined in the scope?
Re:What’s New in ES2019 by munificent on Tuesday July 30, 2019 @01:25PM (#20567016)
The new one shadows it.
Re:What’s New in ES2019 by dotancohen on Wednesday July 31, 2019 @08:54AM (#20574002)
Local scope might not be what the programmer wants, though, depending on circumstance. Pseudocode:

  i = 3;
  foo = \0;

  while ( i-- ) {
      if ( foo = resultFromFooApi() ) {
          break;
      }
      sleep 1;
  }

  return foo;