- The language itself. This is fairly standard among the various environments, both in the various browsers and in the various server-side environments.
- The DOM API - how the language can interact with the various parts of a web page while in the browser. While in this respect the various browsers are getting closer to each other they still differ. Several libraries, most prominently JQuery, is trying to provide a unified API.
- The server API (or just API) provided by Node.js or one of the other server-side systems.
In this series of articles we'll see all 3 major components.
Let's start with a few simple examples we can run in a browser. It is probably the easiest to get started this way, as these examples only require you to have a browser (and if you are reading this, then you probably have one), and a text editor.
Editor or IDE
Any text editor can be used.
On MS Windows you can even use the built-in plain Notepad, but I'd recommend something more powerful. You can download Notepad++ which is very similar to Notepad, but with tons of extra features, or get Aptana Studio. The latter has a steeper learning curve, so you might want to start with the more simple tool.
Embed or include
If you'd like to try it yourself, open your editor and create a file with .html extension (for example hello.html) and put the above code in the file. Then switch to your browser and open the file with the browser. (Most browsers will let you do that using the File/Open File menu option.)
First line <script> document.write("<h1>Hello World</h1>"); </script> Last lineTry!
This function was often used when one wanted to change what's shown. Today, there are some more advanced techniques.
Finally let's see how developers usually print out debugging information.
<script> console.log("Hello World"); </script>Try!
In order to see the console you'll need to open it.
If you happen to use Chrome on OSX you can open the console using: Command-Option-J.
Published on 2015-02-09