Despite the name, JavaScript is only distantly related to the Java programming language, the main similarity being their common debt to the C programming language syntax. Semantically, JavaScript has far more in common with the Self programming language and ActionScript which is also an ECMAScript.
JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.
As of 2006, the latest version of the language is JavaScript 1.7. The previous version 1.6 corresponded to ECMA-262 Edition 3 like JavaScript 1.5, except for Array extras, and Array and String generics. ECMAScript, in simple terms, is a standardized version of JavaScript. The ECMA-357 standard specifies E4X, a language extension dealing with XML.
One major use of web-based JavaScript is to write functions that are embedded in or included from HTML pages and interact with the Document Object Model (DOM) of the page to perform tasks not possible in HTML alone. Some common examples of this usage follow.
target="xxx" to the link element in HTML will reliably produce a new window the same size as the current one, with menus etc displayed as per the user's preferences. Note that many browsers now include mechanisms that, by default, block all JavaScript pop-ups, displaying only a small message to say that they have done so.
The DOM interfaces in various browsers differ and don't always match the W3C DOM standards. Rather than write different variants of a JavaScript function for each of the many browsers in common use today, it is usually possible, by carefully following the W3C DOM Level 1 or 2 standards, to provide the required functionality in a standards-compliant way that most browsers will execute correctly. Care must always be taken to ensure that the web page degrades gracefully and so is still usable by any user who:
Other examples of JavaScript interacting with a web page's DOM have been called DHTML and SPA.
A different example of the use of JavaScript in web pages is to make calls to web and web-service servers after the page has loaded, depending upon user actions. These calls can obtain new information, which further JavaScript can merge with the existing page's DOM so that it is displayed. This is the basis of Ajax programming.
Outside of the Web, JavaScript interpreters are embedded in a number of tools. Adobe Acrobat and Adobe Reader support JavaScript in PDF files. The Mozilla platform, which underlies several common web browsers, uses JavaScript to implement the user interface and transaction logic of its various products. JavaScript interpreters are also embedded in proprietary applications that lack scriptable interfaces. Dashboard Widgets in Apple's Mac OS X v10.4 are implemented using JavaScript. Microsoft's Active Scripting technology supports JavaScript-compatible JScript as an operating system scripting language. JScript .NET is a CLI-compliant language that is similar to JScript, but has further object oriented programming features. Tools in the Adobe Creative Suite, including Photoshop, allow scripting through JavaScript.
Each of these applications provides its own object model which provides access to the host environment, with the core JavaScript language remaining mostly the same in each application.
Because JavaScript is interpreted, loosely-typed, and must run at the client-side in varying environments (host applications), implementations and versions the programmer has to take extra care to make sure the code executes as expected in as wide a range of circumstances as possible, and that functionality degrades nicely when it does not.
Each script block is parsed separately. On pages where JavaScript in script blocks is mixed with HTML, syntax errors can be identified more readily by keeping discrete functions in separate script blocks, or (for preference), using many small linked .js files. This way, a syntax error will not cause parsing/compiling to fail for the whole page, which can help to enable a dignified die.
Similar security issues have been noted with Java, but they are considered a lesser threat because the Java virtual machine provides a well-defined sandboxing model and few Web sites today (2006) require Java, whereas many use JavaScript.
Microsoft's own VBScript, like JavaScript, can be run client-side in web pages. VBScript has syntax derived from Visual Basic and will only run if the web pages are viewed in Internet Explorer.
Due to the success of JavaScript, Microsoft developed a compatible language, which it called JScript. JScript was first supported in Internet Explorer version 3.0, released in August, 1996; when web developers talk about the use of JavaScript in the IE browser, they actually mean JScript.
The need for common specifications for these two languages was the basis of the ECMA 262 standard for ECMAScript (see external links below), three editions of which have been published since the work started in November 1996. The object model of browser-based JavaScript, the Document Object Model (DOM), is actually not part of the ECMAScript standard. It is defined in a set of separate standards, developed by the W3C and is applicable to the access and manipulation of HTML and XML documents in many computer languages and platforms.
ActionScript, the programming language used in Macromedia Flash, is based on the ECMAScript standard, so it closely resembles JavaScript in syntax.
JSON, or JavaScript Object Notation, is a general-purpose data interchange format that is defined as a subset of JavaScript.
JavaScript OSA (JavaScript for OSA, or JSOSA), is a Macintosh scripting language based on the Mozilla 1.5 JavaScript implementation, SpiderMonkey. It is a freeware component made available by Late Night Software. Interaction with the operating system and with third-party applications is scripted via a MacOS object. Otherwise, the language is virtually identical to the core Mozilla implementation. It was offered as an alternative to the more commonly used AppleScript language.
Of only historical interest now, ECMAScript was included in the VRML97 standard for scripting nodes of VRML scene description files.
JavaScript is also considered a functional programming language like Scheme and OCaml because it has closures and supports higher-order functions. The Little Javascripter shows the relationship with Scheme in more detail.
C programming language family | Curly bracket programming languages | Domain-specific programming languages | JavaScript programming language | Prototype-based programming languages | Object-based programming languages | Scripting languages
جافا سكريبت | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | 자바스크립트 | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | JavaScript | ஜாவாஸ்கிரிப்டு | จาวาสคริปต์ | JavaScript | JavaScript | Джава сценарій (мова програмування) | JavaScript
This article is licensed under the GNU Free Documentation License.
It uses material from the
"JavaScript".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world