Shortest* Javascript Code that prints its own Code!
This is one of the challenging tasks for any programming language:
Write a code that prints itself on the terminal!
To make it more interesting… code it short!
I took a shot at javascript and came up with the following code. If you can come up with shorter code, DO POST AS COMMENT!
Lets see who’s short&smart!
The Code (177 chars, tested on FF3):
var dq='"';var q="'";var s='document.write("var dq="+q+dq+q+";var q="+dq+q+dq+";var s="+q+s+q+";"+s);';document.write("var dq="+q+dq+q+";var q="+dq+q+dq+";var s="+q+s+q+";"+s);
Your turn now… I’m waiting!
Write a code that prints itself on the terminal!
To make it more interesting… code it short!
I took a shot at javascript and came up with the following code. If you can come up with shorter code, DO POST AS COMMENT!
Lets see who’s short&smart!
The Code (177 chars, tested on FF3):
var dq='"';var q="'";var s='document.write("var dq="+q+dq+q+";var q="+dq+q+dq+";var s="+q+s+q+";"+s);';document.write("var dq="+q+dq+q+";var q="+dq+q+dq+";var s="+q+s+q+";"+s);
Your turn now… I’m waiting!
This works on Firefox 3 and with slightly different whitespace it works on Safari.
ReplyDeleteIt's 69 chars.
(function () {
document.write("(" + arguments.callee + ")()");
})()