Skip to content

Instantly share code, notes, and snippets.

@anvaka
Last active December 12, 2015 10:18
Show Gist options
  • Save anvaka/4757667 to your computer and use it in GitHub Desktop.
Save anvaka/4757667 to your computer and use it in GitHub Desktop.
Just having fun... This function prints itself to the console.
(function () {
var arr = ["(function () {", "var arr = [", "arr[1] += arr.map(function(x) { return String.fromCharCode(0x22) + x + String.fromCharCode(0x22); }).join(', ') + '];';", "arr.forEach(function(x) { console.log(x); });", "}())"];
arr[1] += arr.map(function(x) { return String.fromCharCode(0x22) + x + String.fromCharCode(0x22); }).join(', ') + '];';
arr.forEach(function(x) { console.log(x); });
}())
(function quine() { console.log('(' + quine.toString() + '())'); }())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment