Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
对象解构赋值 wtf
let reslt, x;
reslt = [...null]; // TypeError: null is not iterable
reslt = [...undefined]; // TypeError: undefined is not iterable
reslt = {...null}; // {}
reslt = {...undefined}; // {}
if (x in null) {}
// TypeError: Cannot use 'in' operator to search for 'undefined' in null
if (x in undefined) {}
// TypeError: Cannot use 'in' operator to search for 'undefined' in undefined
for (x in null) {}
// correct
for (x in undefined) {}
// correct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.