0

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ù

Atrau
  • 1
  • 1
  • Just press `F12` (most browsers) or `Ctrl+Shift+K` (FireFox/Mozilla) and type into the _Console_? – Paul S. Jan 06 '14 at 00:43
  • 1
    See [How run a windows console for JavaScript](http://stackoverflow.com/questions/20737607/how-run-a-windows-console-for-javascript/20738366#20738366). – Theraot Jan 06 '14 at 00:43
  • possible duplicate of [Node.js Unit Testing](http://stackoverflow.com/questions/7254025/node-js-unit-testing) – Quentin Jan 06 '14 at 00:46
  • If you just want to execute JavaScript, get NodeJS and an editor with external commands. In Vim for example you can execute the code in the current buffer with `:w !node`. It's great for quick testing. – elclanrs Jan 06 '14 at 00:49

2 Answers2

1

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.

vahid abdi
  • 9,636
  • 4
  • 29
  • 35
Poyo
  • 554
  • 1
  • 9
  • 23
0

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.

Josh Beam
  • 19,292
  • 3
  • 45
  • 68