subsection contents

Pseudo JavaScript Console

Enter some JavaScript code to evaluate:

"echo" output is displayed here:
// individual statements
echo(typeof (""+1))

// this whole snippet can be entered as a block
var str = "This is a test";
echo(str.substr(1,3) + "tory");
echo(str.replace(/i/g, "1"));
var wordsArray = str.split(" ");
echo("Found " + wordsArray.length + " words");

// special functions
echo(expression) // evaluates and displays expression in output area
cls()            // clears the output area

Netscape Navigator had a handy feature called the JavaScript Console, which allowed direct input of JavaScript statements and displayed any error messages. These days, Firefox has the great Firebug add-on. Such tools are very useful for experimenting and debugging with JavaScript.

Sometimes I was forced to work at places without access to such tools: I only had standard-issue Internet Explorer, which lacked a JavaScript Console. So I wrote this page to provide at least part of that functionality for IE (and other browsers). Just enter some JavaScript code in the top half of form above, and you can run it. Output (via the echo() function that I've defined in the page) will appear in the text area in the bottom half of the form.

For those interested, there's nothing too fancy going on: the page uses the powerful (but potentially dangerous) eval() function.

Warning: Be careful what you type. Some JavaScript code can wreak havoc!

Last updated: April 8, 2009