JavaScript Guide | Part 1

JavaScript Guide | Part 1

JavaScript Scripting Language — Guide

JavaScript is a scripting language commonly used in object-oriented Web sites. It was originally developed by Brendan Eich of Netscape Communications under the name Mocha and later LiveScript, but was later renamed to “JavaScript” and was formalized with a syntax closer to that of Java, Sun Microsystems. JavaScript has been standardized for the first time between 1997 and 1999 under the name ECMAScript by ECMA. The final standard in December 1999, ECMA-262 Edition 3, corresponds to JavaScript 1.5. It is also an ISO standard.

Java, JavaScript, and JScript

The change of name to JavaScript LiveScript occurred more or less at a time when Netscape was including support for Java technology in its Netscape Navigator browser. The choice of name proved a source of great confusion. There is no real relation between Java and JavaScript, and their similarities are mostly in syntax (derived in both cases the C language), their semantics are quite different, and in particular their object models are unrelated and are widely incompatible. Given the success of JavaScript as a language to enrich web pages, Microsoft developed a compatible language known as JScript. The need for common specifications formed the basis to ECMAScript standard ECMA 262, of which three editions have been published since the work began in November 1996.

JavaScript Structural Aspects

The main feature of JavaScript is that it is an interpreted language. The code does not compile but then there is an interpreter (JavaScript client side it is included in the browser you are using) to perform line by line at runtime, as transcribed into the script. JavaScript then presents all the characteristics of a normal interpreted language (and thus its advantages and disadvantages) with a syntax similar to that of a compiled language (it is relatively similar to that of C, C + + and Java), then the possibility of using typical features of high-level programming language (control structures, loops, etc..) and even more the potential to define more complex structures, similar to those taken in normal object-oriented languages (creation prototypes, object instances, manufacturers).

Another important feature of JavaScript is its being a weakly typed language, then the type of variables can not be assigned at declaration and the variables themselves are converted automatically by the interpreter.

JavaScript is also a weak object-oriented language. For example, the inheritance mechanism is more similar to Self and NewtonScript than to the Java language (which is a strongly object-oriented language). The objects themselves are more reminiscent of Perl associative array objects in Java or C + +.

Other aspects of interest: JavaScript client side JavaScript code is executed on the client, then the server is not called. This appears to be an advantage as the presence of particularly complex script the server would not be overloaded. Conversely, if the script showing a considerable amount of data, the time to download may become too long.

Furthermore, working only on the client, any information that requires access to data stored in a database should be postponed to a language that makes explicit transaction and then return the results to one or more JavaScript variables, such operations require loading the page itself. With the advent of AJAX these limits are exceeded.

JavaScript Use

JavaScript is an object-oriented programming language with a syntax loosely based on C. Like C, has the concept of reserved keywords, making it almost impossible to expand the language (being executed directly from source).

As in C, the language has no input or output constructs of its own, while the C libraries relies on standard I / O, a JavaScript engine relies on a host program in which it is incorporated. There are many programs such host, including those relating to the Web are the best known examples. These are examined first.

JavaScript, if integrated into a Web browser, connects through interfaces called DOM (Document Object Model) applications, especially at the server side (web server) and client side (browser) internet applications. Many web sites use client-side JavaScript technology to create powerful dynamic web applications. It can use Unicode and can evaluate regular expressions (introduced in version 1.2, Netscape Navigator 4 and Internet Explorer 4). The expression JavaScript contained in a string can be evaluated using the eval function.

A main use of web-based JavaScript is to write small functions integrated into HTML pages that interact with the DOM of the browser to perform certain actions are not possible with only static HTML, check the values in input fields, hide or display certain elements etc.

Unfortunately, the W3C DOM standard imposed are not always respected by the various browsers: different browsers (even according to their rendering engine) expose different objects or methods to the script (Internet Explorer is usually adhere to standards with minor changes, and is to example the event object as a global, Opera does not support the alert () and confirm ()), and is therefore often necessary to implement additional controls to a JavaScript function, for compatibility with each browser.

Outside of the Web, JavaScript interpreters are embedded in different applications. Adobe Acrobat and Adobe Reader support JavaScript in PDF files. The Mozilla platform, which underlies many popular Web browsers, uses JavaScript to implement the user interface and transaction logic of its various products. JavaScript interpreters are also embedded in proprietary applications without programmable interfaces via script. Finally, the technology of Microsoft Windows Script Host support JavaScript (via JScript) a scripting language for operating systems.

Each of these applications provides its own object model that gives access to the receiving environment, the core JavaScript language remaining mostly unchanged in each application.



Leave your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.