Last active
November 30, 2018 10:34
-
-
Save lumie1337/cd90a2839fddb0cc7e894ebad1dedd82 to your computer and use it in GitHub Desktop.
conditional rest spread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const oldConcat = Array.prototype.concat; | |
Array.prototype.concat = function (...args) { | |
return oldConcat.apply(this, args.map(x => x == null ? [] : x)) | |
} | |
// now this works | |
// Note: only works when actually transpiling to [1,2,3].concat(false && [4,5,6]) | |
// does not actually work in chrome console | |
const some = [ | |
1, | |
2, | |
3, | |
...false && [4,5,6] | |
] | |
// some = [1,2,3] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment