Created
July 9, 2020 20:41
-
-
Save exbotanical/6b6e6c0e6a397d79695521eaa2af4d7d to your computer and use it in GitHub Desktop.
Code Golf with JavaScript
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
/* Nodejs Quines */ | |
// everything is wrapped in its own execution context so you can copy + paste the entire snippet without conflicts; | |
// else, the liberal use of semicolons (and in some instances, the lack thereof) will confuse the interpreter and throw exceptions | |
// IIFE ES6 quine | |
{ | |
(x=_=>console.log(`(x=${x})();`))(); | |
// 36 bytes | |
} | |
// ES6 Quine, shortest I've written thus far | |
{ | |
$=_=>console.log(`$=${$};$()`);$() | |
// 34 bytes | |
} | |
// ES6 Quine writing to stdout | |
{ | |
(y=_=>process.stdout.write(`(y=${y})()`))() | |
// 43 bytes | |
} | |
// Variation | |
{ | |
(x=_=>console.log(`(x=${x.toString()})()`))() | |
// 46 Bytes | |
} | |
// If you have more performant/smaller JS Quines or otherwise suggestions for improvement regarging mine, please do share! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment