Thursday, September 11, 2008

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!

1 comment: