60

What would be a good way to test Javascript on a browser? Should there be a localhost in my computer? and how to create one?

5
  • 8
    ctrl+shift+j -> use console as REPL for testing
    – Raynos
    Jan 15, 2012 at 13:01
  • 5
    have you tried jsfiddle.net ?
    – albertjan
    Jan 15, 2012 at 13:01
  • 20
    Closed as not a real question, yet there are 15 upvotes. Stop being elitists @Matt Fenwick and the rest of you who closed the question. Stop proliferating your attitudes of condescension on this site.
    – Mark C.
    Jul 20, 2017 at 16:59
  • Perfectly reasonable question that I arrived at from a google search. Now 45 upvotes. High time the founding fathers looked at the moderators remit and curtailed the actions of some of the over zealous ones. I had similar problems on the R forum. This sort of moderating risks stopping people asking questions. Despite what your primary teacher told you, seemingly on SE some questions shouldn't be asked. Nov 6, 2020 at 13:44
  • RunJS it's a JavaScript playground that runs your code and gives you instant feedback.
    – Luke Haas
    Dec 16, 2022 at 11:54

3 Answers 3

40

Following is a free list of tools you can use to check, test and verify your JS code:

  1. Google Code Playground
  2. JavaScript Sandbox
  3. jsbin
  4. jsfiddle
  5. pastebin
  6. jsdo.it
  7. firebug
  8. html5snippet.net

Hope this helps.

1
8

If you want to edit some complex javascript I suggest you use JsFiddle. Alternatively, for smaller pieces of javascript you can just run it through your browser URL bar, here's an example:

javascript:alert("hello world");

And, as it was already suggested both Firebug and Chrome developer tools have Javascript console, in which you can type in your javascript to execute. So do Internet Explorer 8+, Opera, Safari and potentially other modern browsers.

2
  • 1
    IE8 and IE9 also have developer tools out of the box.. at least for me they had. Opera and safari have consoles as well.
    – Esailija
    Jan 15, 2012 at 13:10
  • Thanks Esailija, I've amended the answer Jan 15, 2012 at 13:13
5

Install firebug: http://getfirebug.com/logging . You can use its console to test Javascript code. Google Chrome comes with Web Inspector in which you can do the same. IE and Safari also have Web Developer tools in which you can test Javascript.

3
  • 4
    or install node and use the node REPL from the command line
    – Raynos
    Jan 15, 2012 at 13:03
  • 1
    Remember this won't work in IE. If the OP is an IE user, he should quickly install Chrome/Firefox, or use a web-based solution like jsfiddle.net, as mentioned by the_ajp
    – Robbietjuh
    Jan 15, 2012 at 13:09
  • Read–eval–print loop
    – AlvaroFG
    Oct 12, 2017 at 19:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.