OK, this has reached a point where I am annoyed and was not able to solve this.
In ES5 I would frequently do something like...
if( (users = resp.results) && users.length > 0 ) {
// do something with users
}
For a moment, let's forget about the scoping and the implication and all of that...
Babel does not like this syntax anymore starting ES6 nor does the Chrome console.
Is there an equivalent syntax now in ES6?
If you want it to be valid when using 'use strict'
, which Babel enforces, you need to declare users
first. If you are not using Babel or 'use strict' your original code will work just fine.
var users;
if( (users = resp.results) && users.length > 0 ) {
// do something with users
}
will work with 'use strict'
.
You could also manually remove 'use strict'
from the top of your converted babel code if you want to continue using this trick.