Quine: Difference between revisions

Content added Content deleted
(Added C3 example)
m (→‎{{header|JavaScript}}: New quine with javascript-flavored decodeURI along without any use of implicit "stringify", "eval" or template literal functionalities.)
Line 1,785: Line 1,785:
=== Replacing String ===
=== Replacing String ===
<syntaxhighlight lang="javascript">(function(){str=["(function(){str=[F].join(String.fromCharCode(34));str=str.replace(/F/,String.fromCharCode(34)+str+String.fromCharCode(34));console.log(str)})()"].join(String.fromCharCode(34));str=str.replace(/F/,String.fromCharCode(34)+str+String.fromCharCode(34));console.log(str)})()</syntaxhighlight>
<syntaxhighlight lang="javascript">(function(){str=["(function(){str=[F].join(String.fromCharCode(34));str=str.replace(/F/,String.fromCharCode(34)+str+String.fromCharCode(34));console.log(str)})()"].join(String.fromCharCode(34));str=str.replace(/F/,String.fromCharCode(34)+str+String.fromCharCode(34));console.log(str)})()</syntaxhighlight>

=== encodeURI as string escapes ===
Functions like <code>encodeURI/decodeURI</code> benefit js with highly controllable string escapes, like the quotes, newlines, etc. Thus, the following js-flavored quine requires no explicit or implicit <code>stringify</code>, <code>eval</code> or template literals functionalities:
<syntaxhighlight lang="javascript">let x="let x=%22quinner%22; alert(decodeURI(x).replace(%22quinner%22, x));"; alert(decodeURI(x).replace("quinner", x));
</syntaxhighlight>


===Code As Data===
===Code As Data===