Videos
What is a JavaScript compiler?
How fast is the online JavaScript compiler?
Does the JavaScript compiler work offline?
Factsheet
Sorry for asking this I suposse this gets asked a lot here but I could not find any info on the matter.
I am learning js for web developing but I already know python. I have been learning for 2 days and today I started js codewars.
Everytime I want to set up an exercise I have to create an html file, link the file to the html, launch the html in the browser, write the code in the js file, open the console on firefox and check if my function has the correct output (I use console.log to check)
It gets old real quick when you have to do that 10 times a day. In python I would just click "run" and that's it.
Is there anyway to check the output on vs code without having to set up the whole thing?
Following is a free list of tools you can use to check, test and verify your JS code:
- Google Code Playground
- JavaScript Sandbox
- jsbin
- jsfiddle
- pastebin
- jsdo.it
- firebug
- html5snippet.net
Hope this helps.
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.
I'm pulling my hair out trying to figure out how to unit test my website's javascript. It seems like most popular tools (ex. Mocha) only work in Node.JS.
If you are trying to just test the functionality of your JavaScript file: create a blank HTML file, add a link to your JS file as you would normally load a JS file from HTML, and open the HTML file in Chrome. Go to the JavaScript console. You'll be able to interact with the functionality of your JS code as usual. You wouldn't need to set up a server for this. If still not clear, here's an example:
<html>
<head>
<script type = "text/javascript" src = "path/to/your/jsfile"></script>
</head>
</html>
You can use a light weight webserver to serve the file.
For example,
1. install Node
2. install the "http-server" (or similar) package
3. Run the http-server package ( "http-server -c-1") from the folder where the script file is located
4. Load the script from chrome console (run the following script on chrome console
var ele = document.createElement("script");
var scriptPath = "http://localhost:8080/{scriptfilename}.js" //verify the script path
ele.setAttribute("src",scriptPath);
document.head.appendChild(ele)
- The script is now loaded the browser. You can test it from console.