Reputation: 11
I am looking for a way to test my JavaScript without using html.
Similar to JS Fiddle or JS Bin, But I want to be able to execute the JavaScript in the output window without having to place it inside HTML
eg
function out()
{
var x = 5;
var y = 10;
z = x * y;
return z;
}
alert(out());
and have the output window print 50
Thanks for the help
Atraù
Upvotes: 1
Views: 2212
Reputation: 623
JavaScript code can be executed without actually using an HTML document quite easily.
Pressing Ctrl+Shift+J in Internet Explorer or Chrome, and Ctrl+Shift+K in Firefox will lead you to the console, in which you can paste your JavaScript code to be executed. Usually, the best thing to do is to type your commands one at a time, with your function definition first and then the alert()
next.
To be safe, do this on about:blank to make sure that there are no conflicting variables.
Upvotes: 2
Reputation: 19772
If you are using Firefox, you can get an add-on called "Firebug".
It has a lot of features, and whenever you run your scripts, it'll show you errors, etc.
In Chrome, go to View --> Developer --> JavaScript Console.
Lots of features, too. A little bit different UI, depends on what you like.
Upvotes: 0