JavaScript

From Citizendium
(Redirected from Java script)
Jump to navigation Jump to search
This article is a stub and thus not approved.
Main Article
Discussion
Related Articles  [?]
Bibliography  [?]
External Links  [?]
Citable Version  [?]
 
This editable Main Article is under development and subject to a disclaimer.
JavaScript
Created by Brendan Eich
Typing discipline weak, dynamic

JavaScript is a general-purpose computer programming language defined by a series of standards by ECMA International (ECMA) and known as ECMAScript. JavaScript runs in a web browser to help make web pages interactive. Despite standardization, web browsers from different companies (or even different versions of a browser from the same company) may not handle JavaScript identically. The uneven treatment of JavaScript by different web browsers is the single greatest challenge in JavaScript programming. It is one reasons why so many programmers use a toolkit (Javascript library) such as jQuery instead, and it then becomes the responsibility of the library authors to handle the browser differences correctly in JavaScript.

JavaScript is not related to the Java programming language, despite the similar name. JavaScript was originally called LiveScript, but was re-branded due to a deal between Netscape and Sun Microsystems, whereby Netscape used the name JavaScript, a Sun trademark,[1] in return for bundling Sun's Java runtime with the popular Netscape Browser[2]. JavaScript was intended as a complement to Java and so was designed to look similar.

When JavaScript code is embedded in HTML pages, web browsers will execute the JavaScript upon loading the web page, and some Javascript may execute when the user interacts with elements in the web page. The JavaScript within HTML may also execute in response to user actions on the page. Since in some cases JavaScript may be disabled in the web browser's options, well-designed HTML pages must be functional even if the JavaScript within them is not allowed to execute.

JavaScript has seen several versions since its initial introduction with Netscape Navigator 2.0 in 1995 and the latest version now include new features making it a more robust scripting language. JavaScript script received an added boost when the browser started to expose more of the document object model (DOM) and allowed dynamic changes to the DOM; HTML elements became available to JavaScript programmers, as were the events allowing JavaScript coded functions to handle those events. This provided a better user experience for web surfers. Allowing the HTML document to manipulated after the page was served and/or based on user interactions made JavaScript important for the world wide web.

The use of JavaScript to communicate in the background with a web server, and then to update small parts of an HTML page asynchronously without the delay or flashing associated with postback (in which the web server sends the browser a completely new HTML page) is broadly called Ajax. In fact, using JavaScript in this manner is so complex that many programmers do not work with JavaScript directly but instead, use one of many Ajax toolkits which group JavaScript into higher functions.

JavaScript supports all the structured programming syntax of C (e.g., if statements, while loops, switch statements, etc.). JavaScript is almost object-based. JavaScript relies on a run-time environment.

References