Skip to content

Instantly share code, notes, and snippets.

@vilhalmer
Created September 30, 2012 23:49
Show Gist options
  • Save vilhalmer/3808763 to your computer and use it in GitHub Desktop.
Save vilhalmer/3808763 to your computer and use it in GitHub Desktop.
A less "cheaty" quine in JavaScript.
(function()
{
var q = String.fromCharCode(34);
var quine = [
"(function()",
"{",
" var q = String.fromCharCode(34);",
" var quine = [",
" ",
" ];",
" for (var i = 0; i < 4; ++i;)",
" {",
" console.log(quine[i]);",
" }",
" for (var i = 0; i < quine.length; ++i)",
" {",
" console.log(quine[4] + q + quine[i] + q + ',');",
" }",
" for (var i = 5; i < quine.length; ++i;)",
" {",
" console.log(quine[i]);",
" }",
"}());",
];
for (var i = 0; i < 4; ++i)
{
console.log(quine[i]);
}
for (var i = 0; i < quine.length; ++i)
{
console.log(quine[4] + q + quine[i] + q + ',');
}
for (var i = 5; i < quine.length; ++i)
{
console.log(quine[i]);
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment