Skip to content

Instantly share code, notes, and snippets.

@jasondentler
Created January 18, 2012 03:05
Show Gist options
  • Save jasondentler/1630601 to your computer and use it in GitHub Desktop.
Save jasondentler/1630601 to your computer and use it in GitHub Desktop.
Wat!
function print(value) {
if (typeof(value) == 'string')
return WScript.stdout.write(value);
if (typeof(value) == 'number') {
if (isNaN(value))
return WScript.stdout.write('NaN');
return WScript.stdout.write(value);
}
if (value == null)
return print("null");
if (value instanceof Array) {
return String(value);
}
WScript.Echo(value);
};
function output(value) {
if (value instanceof Array) {
WScript.Echo('Array with ' + value.length + ' elements');
print(value);
}
WScript.Echo(typeof(value));
print(value);
WScript.Echo('');
}
var line = null;
while (line != '') {
WScript.stdout.write(">");
line = WScript.stdin.readline();
if (line != '') {
try {
var x = eval(line);
output(x);
} catch (e) {
WScript.Echo('Error: ' + e.message);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment