Skip to content

Instantly share code, notes, and snippets.

@noinkling
Last active May 14, 2017 07:13
Show Gist options
  • Save noinkling/218dc503dc6bb5f844fa53c8a0bc1d32 to your computer and use it in GitHub Desktop.
Save noinkling/218dc503dc6bb5f844fa53c8a0bc1d32 to your computer and use it in GitHub Desktop.
Webpack module bug
export default 'foo';
import foo from './foo';
const bar = 'bar';
let val;
[ val = bar ] = [];
console.log(val); // "bar"
({ val = bar } = {});
console.log(val); // "bar"
const [ val2 = foo ] = [];
console.log(val2); // "foo"
const { val3 = foo } = {};
console.log(val3); // "foo"
[ val = foo ] = []; // ReferenceError: foo is not defined
({ val = foo } = {}); // ReferenceError: foo is not defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment