Skip to content

Instantly share code, notes, and snippets.

@cowboy
Last active June 29, 2024 15:25
Show Gist options
  • Save cowboy/6966747ad374fb97b0ab to your computer and use it in GitHub Desktop.
Save cowboy/6966747ad374fb97b0ab to your computer and use it in GitHub Desktop.
A few JavaScript quines
// Today, I noticed that someone favorited this tweet of mine from 2012:
// https://twitter.com/cowboy/status/232587756486938624
// !function $(){console.log('!'+$+'()')}() #quine
// So I fooled around for a little bit:
// Shortest JavaScript quine?
(function _(){return'('+_+')()'})()
// Have fun with this one!
(function $($_$,_,_$,_$_,$_){return[_=_[$_$](_$[$_++])][_[$_++]][_[$_++]]([][_[$_--]][_[$_++]](_$_,function($$){return _$[$$]||[$_,_$_,_,$_$,$][$_--]},$_++),_[++$_])})('split',',join,call,map',',()\'\\','1821383038303012434430383082',0)
// Test a quine like so:
a= your_quine_code
a===eval(a) // must be true
// Eg.
a= (function _(){return'('+_+')()'})()
a===eval(a) // true
@rubyswolf
Copy link

oh I missed that one oops @donno2048

@zoqol
Copy link

zoqol commented Dec 18, 2022

without equality sign and function keyword

 ({0(){alert(`({${this[0]}})[0]()`)}})[0]()

@qtheperfect
Copy link

// Never ending eval...
let x ="let x =%22quinner%22;let y=decodeURI(x).replace(/quinner/, x);alert(y);eval(y);";let y=decodeURI(x).replace(/quinner/, x);alert(y);eval(y);

@qtheperfect
Copy link

// Never ending eval...
let x ="let x =%22quinner%22;let y=decodeURI(x).replace(/quinner/, x);alert(y);eval(y);";let y=decodeURI(x).replace(/quinner/, x);alert(y);eval(y);

@timothyferriss
Copy link

A quine in programming is a self-replicating code that, when executed, produces retro bowl its own source code as the output.

@jeffreesta
Copy link

You can test any quine by assigning it to the variable a and then fnaf game checking if a === eval(a) returns true. If it does, the code is a valid quine.

@jedwards1211
Copy link

You can test any quine by assigning it to the variable a and then fnaf game checking if a === eval(a) returns true. If it does, the code is a valid quine.

AI sure is making spam more insidious

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment