Running JavaScript
To evaluate a piece of JavaScript code, you need to call it in a HTML file and view the file in browser.Here's how to embed JavaScript into HTML. If you just have few lines of code, do:
If you have more than a few lines of code, put them in a file, and call it like this:
Use Browser's Web Developer Console:
In Google Chrome: 〖Tools ▸ JavaScript Console〗 .
In Firefox: 〖Tools ▸ Web Developer ▸ Web Console〗.
In Safari: 〖Develop ▸ Show Error Console〗.
In Internet Explorer 9: 〖Tools ▸ F12 Developer Tools〗.
Using node.js
On Linux, install by
sudo apt-get install nodejs
. Or get it at http://nodejs.org/.You can run it interactively. Type
node
to start the interactive prompt. Type Ctrl+d to exit.You can also run it as shell script. Save a JavaScript code in a file “myscript.js”. Then, you can run the script in shell like this:
node myscript.js
.
0 comments:
Post a Comment