JavaScript: Difference between revisions

Content deleted Content added
m Template updated. Links: updated, WPDisambiguated; cut needless: pipes, underscores. Decapitalized: nonproper noun MOS:CAPS, nonacronym WP:ALLCAPS. Trademark MOS:TM tag cut. WP:SLASHes replaced. WP:ABBReviations defined. More.
Line 9:
| developer= [[Netscape Communications Corporation]], [[Mozilla Foundation]]
| latest_release_version = 1.8.2<ref>[https://developer.mozilla.org/en/firefox_3.6_for_developers#JavaScript Firefox 3.6 supports JavaScript 1.8.2]</ref>
| latest_release_date = {{releasestart date and age|2009|6|22}}
| latest_preview_version = 1.8.5<ref>
{{cite web
Line 18:
|accessdate=August 10, 2010
}}</ref>
| latest_preview_date = {{Releasestart date and age|2010|7|27}}
| typing = [[dynamic typing|dynamic]], [[weak typing|weak]], [[duck typing|duck]]
| implementations = [[KDE'sKJS JavaScript engine(KDE)|KJS]], [[Rhino (JavaScript engine)|Rhino]], [[SpiderMonkey (JavaScript engine)|SpiderMonkey]], [[V8 (JavaScript engine)|V8]], [[WebKit]], [[Presto_Presto (layout_enginelayout engine)#ECMAScript_enginesECMAScript engines|Carakan]], [[Chakra (JScript engine)|Chakra]]
| influenced_by = [[C (programming language)|C]], [[Java (programming language)|Java]], [[Perl]], [[Python (programming language)|Python]], [[Scheme (programming language)|Scheme]], [[Self (programming language)|Self]]
| influenced = [[ActionScript]], [[CoffeeScript]], [[Dart (programming language)|Dart]], [[JScript .NET]], [[Objective-J]], [[QML]], TIScript
| license =
Line 67:
 
== History ==
{{quote box|width = 200px|Anyway I know only one [[programming language]] worse than [[C (programming language)|C]] and that is Javascript. [...] I was convinced that we needed to build-in a programming language, but the developers, [[Tim Berners-Lee|Tim]] first, were very much opposed. It had to remain completely declarative. Maybe, but the net result is that the programming-vacuum filled itself with the most horrible [[Kludgekludge|kluge]] in the history of computing: Javascript.|[[Robert Cailliau]]<ref>[[wikinews:Wikinews:Story preparation/Interview with Robert Cailliau]]</ref>}}
JavaScript was originally developed by [[Brendan Eich]] of Netscape under the name ''Mocha'', which was later renamed to ''LiveScript'', and finally to JavaScript mainly because it was more influenced by the [[Java programming language]].<ref>{{cite web|last=Krill |first=Paul |url=http://www.infoworld.com/article/08/06/23/eich-javascript-interview_1.html |title=JavaScript creator ponders past, future |publisher=InfoWorld |date=2008-06-23 |accessdate=2009-05-19}}</ref><ref name="computerworld">{{cite web|last=Hamilton|first=Naomi|url=http://www.computerworld.com.au/article/255293/-z_programming_languages_javascript|title=The A-Z of Programming Languages: JavaScript|publisher=computerworld.com.au|date=2008-06-31}}</ref>
LiveScript was the official name for the language when it first shipped in beta releases of Netscape Navigator 2.0 in September 1995, but it was renamed JavaScript in a joint announcement with Sun Microsystems on December 4, 1995,<ref>[http://web.archive.org/web/20070916144913/http://wp.netscape.com/newsref/pr/newsrelease67.html Press release announcing JavaScript], "Netscape and Sun announce Javascript(TM)", PR Newswire, DecDecember 4, 1995</ref> when it was deployed in the Netscape browser version 2.0B3.<ref name="techvision">{{cite web |archiveurl=http://web.archive.org/web/20080208124612/http://wp.netscape.com/comprod/columns/techvision/innovators_be.html |archivedate=2008-02-08 |title=TechVision: Innovators of the Net: Brendan Eich and JavaScript |publisher=Web.archive.org |date= |accessdate=2010-06-14}}</ref>
 
The change of name from LiveScript to JavaScript roughly coincided with Netscape adding support for Java technology in its [[Netscape Navigator]] web browser. The final choice of name caused confusion, giving the impression that the language was a spin-off of the [[Java programming language]], and the choice has been characterized by many as a marketing ploy by Netscape to give JavaScript the cachet of what was then the hot new web- programming language.<ref>{{cite web|url=http://www.webdevelopersnotes.com/basics/languages_on_the_internet.php3 |title=Programming languages used on the Internet and the World Wide Web (WWW) |publisher=Webdevelopersnotes.com |date= |accessdate=2009-05-19}}</ref><ref>{{cite web|url=http://safari.oreilly.com/0596101996/jscript5-CHP-1 |title=O'Reilly - Safari Books Online - 0596101996 - JavaScript: The Definitive Guide, 5th Edition |publisher=Safari.oreilly.com |date= |accessdate=2009-05-19}}</ref>
It has also been claimed{{citation}} that the language's name is the result of a co-marketing deal between [[Netscape]] and [[Sun Microsystems|Sun]], in exchange for Netscape bundling Sun's Java runtime with its [[Usage_share_of_web_browsersUsage share of web browsers#GVU_WWW_user_survey_.281994GVU WWW user survey (1994-01_to_199801 to 1998-10.29)|then-dominant browser]].
 
JavaScript very quickly gained widespread success as a client-side scripting language for web pages. As a consequence, [[Microsoft]] named its implementation [[JScript]] to avoid trademark issues. JScript added new date methods to fix the [[Year 2000 problem|Y2K]]-problematic methods in JavaScript, which were based on Java's <code>[http://java.sun.com/j2se/1.4.2/docs/api/java/util/Date.html java.util.Date]</code> class.<ref name="popularity">{{cite web|url=http://brendaneich.com/2008/04/popularity/ |title=Popularity |author=Brendan Eich |date=3 April 2008 |accessdate=2012-01-19}}</ref> JScript was included in [[Internet Explorer]] 3.0, released in August 1996.
Line 117:
* conditional <code>catch</code> clauses
* iterator protocol adopted from [[Python (programming language)|Python]]
* shallow [[Generatorgenerator (computer scienceprogramming)|generators]]/-[[coroutine]]s also adopted from Python
* [[List comprehension|array comprehensions]] and generator expressions also adopted from Python
* proper block scope via the <code>let</code> keyword
Line 127:
{{Main|JavaScript syntax}}
 
{{As of|2011}}, the latest version of the language is JavaScript 1.8.5. It is a superset of [[ECMAScript]] (ECMA-262) Edition 3. Extensions to the language, including partial [[E4XECMAScript for XML]] (E4X) (ECMA-357) support and experimental features considered for inclusion into future ECMAScript editions, are documented here.<ref>{{cite web|url=https://developer.mozilla.org/en/JavaScript/Reference/About#JavaScript_history |title=MDN - About this Reference |publisher=Developer.mozilla.org |date=2008-08-31 |accessdate=2009-05-19}}</ref>
 
=== Simple examples ===
Line 265:
* Transmitting information about the user's reading habits and browsing activities to various websites.{{Which?|date=December 2011}} Web pages frequently do this for [[web analytics]], [[ad tracking]], [[personalization]] or other purposes.{{Citation needed|date=December 2011}}
 
Because JavaScript code can run locally in a user's browser (rather than on a remote server), the browser can respond to user actions quickly, making an application more responsive. Furthermore, JavaScript code can detect user actions which HTML alone cannot, such as individual keystrokes. Applications such as [[Gmail]] take advantage of this: much of the user-interface logic is written in JavaScript, and JavaScript dispatches requests for information (such as the content of an e-mail message) to the server. The wider trend of [[AJAX|Ajax (programming)|Ajax]] similarly exploits this strength.
 
A [[JavaScript engine]] (also known as ''JavaScript interpreter'' or ''JavaScript implementation'') is an [[interpreter (computing)|interpreter]] that interprets JavaScript [[source code]] and executes the [[computer program|script]] accordingly. The first JavaScript engine was created by [[Brendan Eich]] at [[Netscape Communications Corporation]], for the [[Netscape Navigator]] [[web browser]]. The engine, code-named [[SpiderMonkey (JavaScript engine)|SpiderMonkey]], is implemented in [[C (programming language)|C]]. It has since been updated (in JavaScript 1.5) to conform to ECMA-262 Edition 3. The [[Rhino (JavaScript engine)|Rhino]] engine, created primarily by Norris Boyd (formerly of Netscape; now at Google) is a JavaScript implementation in [[Java (programming language)|Java]]. Rhino, like SpiderMonkey, is ECMA-262 Edition 3 compliant.
 
A web browser is by far the most common host environment for JavaScript. Web browsers typically use the public [[application programming interface|API]] to create "host objects" responsible for reflecting the [[Document Object Model|DOM]] (DOM) into JavaScript. The [[web server]] is another common application of the engine. A [[Server-side JavaScript|JavaScript webserver]] would expose host objects representing an [[HTTP]] request and response objects, which a JavaScript program could then manipulate to dynamically generate web pages.
 
Because JavaScript is the only language that the most popular browsers share support for, it has become a [[target language (computing)|target language]] for many frameworks in other languages, even though JavaScript was never intended to be such a language.<ref name="computerworld" /> Despite the performance limitations inherent to its dynamic nature, the increasing speed of JavaScript engines has made the language a surprisingly feasible compilation target.
Line 282:
<head><title>simple page</title></head>
<body>
<h1 id="header">This is JavascriptJavaScript</h1>
<script type="text/javascript">
document.write('Hello World!');
Line 300:
Because JavaScript runs in widely varying environments, an important part of testing and debugging is to test and verify that the JavaScript works across multiple browsers.
 
The [[Document object model|DOM]] interfaces for manipulating web pages are not part of the ECMAScript standard, or of JavaScript itself. Officially, the DOM interfaces are defined by a separate standardization effort by the [[World Wide Web Consortium|W3C]]; in practice, browser implementations differ from the standards and from each other, and not all browsers execute JavaScript.
 
To deal with these differences, JavaScript authors can attempt to write standards-compliant code which will also be executed correctly by most browsers; failing that, they can write code that checks for the presence of certain browser features and behaves differently if they are not available.<ref>Peter-Paul Koch, [http://www.quirksmode.org/js/support.html Object detection]</ref> In some cases, two browsers may both implement a feature but with different behavior, and authors may find it practical to detect what browser is running and change their script's behavior to match.<ref>Peter-Paul Koch, [http://www.evolt.org/node/23335 Mission Impossible - mouse position]</ref><ref>Peter-Paul Koch, [http://www.quirksmode.org/js/detect.html Browser detect]</ref> Programmers may also use libraries or toolkits which take browser differences into account.
Line 411:
=== Application platform ===
* [[ActionScript]], the programming language used in [[Adobe Flash]], is another implementation of the ECMAScript standard.
* The [[Mozilla]] platform, which underlies [[Mozilla Firefox|Firefox]], [[Mozilla Thunderbird|Thunderbird]], and some other web browsers, uses JavaScript to implement the [[graphical user interface]] (GUI) of its various products.
* [[Adobe Integrated Runtime]] is a JavaScript runtime that allows developers to create desktop applications.
* [http://www.mynfc.org/ myNFC.org] is a JavaScript based framework that allows developers to create applications for smart phones.
Line 457:
| 1.2 || June 1997 || || 4.0-4.05 || || || || ||
|-
| 1.3 || October 1998 || ECMA-262 1st edition / ECMA-262+ 2nd edition || 4.06-4.7x || || 4.0 || || ||
|-
| 1.4 || || || Netscape<br />Server || || || || ||
Line 463:
| 1.5 || November 2000 || ECMA-262 3rd edition || 6.0 || 1.0 || 5.5 (JScript 5.5),<br />6 (JScript 5.6),<br />7 (JScript 5.7),<br />8 (JScript 5.8) || 6.0 || 3.0-5 || 1.0-10.0.666
|-
| 1.6 || November 2005 || 1.5 + Arrayarray extras + Arrayarray and Stringstring generics + [[E4X]] || || 1.5 || || || ||
|-
| 1.7 || October 2006 || 1.6 + Pythonic generators + Iteratorsiterators + let || || 2.0 || || || ||
|-
| 1.8 || June 2008 || 1.7 + [[Generatorgenerator (computer scienceprogramming)|Generatorgenerator expressions]] + [[Closureclosure (computer science)|Expressionexpression closures]] || || 3.0 || || 11.50 || ||
|-
| 1.8.1 || || 1.8 + [[JSON#Native_encoding_and_decoding_in_browsers|Native encoding and decoding in browsers|native JSON]] support + Minorminor Updatesupdates || || 3.5 || || || ||
|-
| 1.8.2 || June 22, 2009 || 1.8.1 + Minorminor updates || || 3.6 || || || ||
|-
| 1.8.5 || July 27, 2010 || 1.8.2 + [[ECMAScript]] 5 Compliancecompliance || || 4 || 9 || 11.60 || ||
|}
 
Line 482:
[[jQuery]] and [[Prototype JavaScript Framework|Prototype]] are popular JavaScript libraries designed to simplify [[DOM]]-oriented client-side HTML scripting.
 
Mozilla browsers currently support [[LiveConnect]], a feature that allows JavaScript and Java to intercommunicate on the web. However, Mozilla-specific support for LiveConnect is scheduled to be phased out in the future in favor of passing on the LiveConnect handling via [[NPAPI]] to the Java 1.6+ plug-in (not yet supported on the Mac {{as of|March 2010|lc=ony}}).<ref>[http://java.sun.com/javase/6/webnotes/6u10/plugin2/liveconnect/ Java.sun.com]</ref> Most browser inspection tools, such as [[Firebug (web development)|Firebug]] in Firefox, include JavaScript interpreters that can act on the visible page's DOM.
 
=== Use as an intermediate language ===
Line 506:
== See also ==
{{Portal|Computer programming}}
* [[Ajax (programming)|]] – Asynchronous JavaScript and XML (Ajax)]] -, a group of web development methods used to create interactive web applications
* [[Comparison of JavaScript-based source code editors]]
* [[Comparison of JavaScript frameworks]]
* [[Document Object Model|Document Object Model]] (DOM)]] - a convention for representing and interacting with objects in HTML, XHTML, and XML documents
* [[Dynamic HTML]] - an umbrella term for a collection of technologies used to create interactive web sites
* [[ECMAScript]] - JavaScript is an ECMAScript implementation
* [[JavaScript engine]] - a specialized computer software which interprets and executes JavaScript
* [[JSON|JavaScript Object Notation (JSON)]] - lightweight text-based open standard designed for human-readable data interchange
* [[JavaScript syntax]]
* [[Unobtrusive JavaScript]] - a general approach to the use of JavaScript in web pages
* [[Dart (programming language)|Dart]] - a replacement for JavaScript
* [[Progressive enhancement]]
{{Clear}}
Line 554:
** [https://developer.mozilla.org/en/A_re-introduction_to_JavaScript Re-Introduction to JavaScript]
* [http://eloquentjavascript.net/ Eloquent JavaScript]
* [http://dev.opera.com/articles/javascript/ JavaScript - Opera Developer Community]
* [http://www.html5libs.com/ JavaScript Libraries Comparison Matrix Tool]
 
Line 560:
{{ECMAScript}}
 
{{DEFAULTSORT:JavascriptJavaScript}}
[[Category:Cross-platform software]]
[[Category:JavaScript| ]]