Skip to content

Instantly share code, notes, and snippets.

@justjavac
Created January 29, 2018 05:21
Show Gist options
  • Save justjavac/bfaac2f36ab52c1fdda1ce156bf27155 to your computer and use it in GitHub Desktop.
Save justjavac/bfaac2f36ab52c1fdda1ce156bf27155 to your computer and use it in GitHub Desktop.
对象解构赋值 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