-->

Saturday, 1 November 2014

Getting started javascript tutorials by example

Getting started javascript tutorials by example

This page will quickly get you started on JavaScript the language. You need to have basic understanding of the language before you can script the DOM/web.

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

Another good way to run JavaScript code is node.js. With node.js, you can run JavaScript like shell scripts in terminal.
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.

Read other related articles

Also read other articles

© Copyright 2019 Project Source Code | All Right Reserved