JavaScript, for dynamic web pages and beyond
Since Netscape created JavaScript to program dynamic HTML pages, applications have continued to expand.
It is used also to enable scripting
in some applications of markup languages (PDF, photoshop, XUL, use JavaScript) and even for system programming!
It was successively called Moka, then LiveScript and finally in agreement with Sun, JavaScript.
JScript is a compatible version implemented by Microsoft in 1996, for Windows
only.
The format described here is ECMAScript 1.5, the standard defined by the ECMA group in 1999. More recent version exists, but not supported by all browsers.
Features

JavaScript in Eclipse
- The syntax of the language is similar to that of Java or C.
- Dynamic variables. Declared as var without type, data of different types can be assigned to a same variable. Firefox in the version 9 introduced type inference which makes the compiler can process variables as typed and speed up the processing considerably.
- Object oriented, uses elements of the page as objects. Dynamic objects.
- No file management nor input-output functions (but dialogue boxes).
Local file access is provided in HTML 5. - Control of the browser.
- Events.
- Dynamic and associative arrays.
- Primitive types (but undeclared) are: boolean, string, number, date, array.
- Build-in Date, Math, RegExp objects.
- A for..in construct allows to scan an array.
- Functions are declared with the function keyword, without return type.
- Operators are those of Java plus strict ones: === and !==, for comparing both values and types.
- Elements of a web page are accessed as a hierarchy of objects, including those of the Document Object Model (DOM, a standard by the W3C): document, window, form, table, etc...
Sample code
Displaying a text.
<script language ="JavaScript1.2">
var demo = "demo";
function dispstring(str)
{
for(i = 0; i < str.length; i++)
{
document.write(str.substring(i, i+1));
}
}
dispstring(demo);
</script>
Why use it?
Building dynamic web pages, client-side processing. JavaScript is more
and more often used as a part of Ajax,
an asynchronous protocol for updating content of web pages with data taken
from the server.
JavaScript
Frameworks are developped to build graphical interfaces for web applications.
It is used also to program XML-based graphical user interfaces.
A system language?
With the advent of JavaScript compilers, operating both in the browser or as a standalone tool, new uses are emerging for this C-like language but even freer, and with an automatic memory management, a sandbox.
- JSLinux.
This project allows you to run Linux in the browser. Program may be edited, compiled and ran at the command line. For a persistent storage, see this version of JSLinux. - Node.js.
A web server oriented events based on the V8 compiler running as an standalone program.
Yahoo! has created the framework Cocktail, based on HTML 5 and Node.js to make online applications that works with or without a browser, online or locally. A sandbox. - Python to Node.js
Experience on the use of Python and Node.js as application server.
Documents
- Manual of the JavaScript language. Understanding the functions with examples and demos.
- JSON
A data format in JavaScript syntax. - JavaScript
in depth
Discussion of special features of JavaScript. - ECMAScript
The official 1999 definition of the language by ECMA. - JavaScript history.
Extensions
- River Trail.
Extension to JavaScript provided as a plugin that allows parallel programming.
Used with WebGL for example, it allows to handle thousands of objects simultanously. - E4X is an extension to ECMAScript 1.7 for an easier processing of XML documents. Used belong Ajax, it can make use of XML simpler, but for now not all browser implement the extension.
- HTML 5 frameworks
JavaScript libraries using Canvas.
Tools
You can develop a JavaScript app in Eclipse (see image above) or a simple script with any editor. It is strongly recommanded to use an Ajax framework or an HTML 5 library to build a serious application.
- JavaScript
The official project at Mozilla (formerly Netscape). - JSLint
Online tool to test your JavaScript code and find errors (by JSON creator). - Directory
The Dmoz JavaScript directory offers a lots of tutorials, examples, and other resources. - Rhino
Standalone JavaScript compiler to Java bytecode. Can be used in command line. - V8 Compiler
Download the JavaScript compiler. - Emscriptem
Compile LLVM bytecode to JavaScript. So any language compiled by LLVM such as C++ may be converted to JavaScript. Demos includes the Doom game running in the browser.
| Tweet |
|