TAGS: JavaScript, Programming, TECH
JavaScript (JS) is the dominant client-side scripting language of the Web. JS is a dynamic (or interpreted: Executes somethings at run-time instead of at compiling), weakly-typed (or loosely-typed: A variable may change its data type), prototype-based (object oriented but instead of classes, the .prototype of an instance affects all other instances) programming language with first-class functions (functions can be first-class objects which allows their creation and modification at run-time) and closures (functions can enclosed as a parameter of another function AND can refer to bound variables, i.e. variables visible at the time the enclosing function was defined).
JavaScript was developed by Brendan Eich at Netscape Communications Corporation, first as Mocha, then as LiveScript, then as JavaScript as part of the Netscape browser v2.0B3 in 1995-12. JavaScript has no relation to Java other than they both use a syntax similar to the c language and that Java was the hot new language at the time. EG: c is a procedural language, while c++ is class-based object oriented language, while JavaScript is a prototype-based object oriented language (like the language Self). JavaScript became widely popular and Microsoft implemented it as JScript in Internet Explorer 3.0 in 1996-08. Netscaped submitted JavaScript to Ecma International for standardization, which resulted in ECMA-262 or ECMAScript in 1997-06. Since then ECMAScript is the standard and it has various dialects, some with their own extensions, and some (EG: Flash's ActionScript) that are quite different. The main dialects includes Netscape's/Mozilla's JavaScript and Microsoft's JScript.
| Date | JavaScript | JScript | ECMAScript |
|---|---|---|---|
| 1996-03 | 1.0 in NS 2.0 | ||
| 1996-08 | 1.1 in NS 3.0 | 1.0 in IE 3.0 | |
| 1997-01 | 2.0 in IIS 3.0 | ||
| 1997-06 | 1.2 in NS 4.0 | 1 | |
| 1997-10 | 3.0 in IE 4.0 and VS 6.0 | ||
| 1998-06 | 2 | ||
| 1998-10 | 1.3 in NS 4.06 | ||
| 1998-10 | 1.4 in NS 4.7 | ||
| 1999-03 | 5.0 in IE 5.0 | ||
| 1999-12 | 3 | ||
| 2000-07 | 5.5 in IE 5.5 | ||
| 2000-11 | 1.5 in NS 6.0 and FF 1.0 | ||
| 2001-10 | 5.6 in IE 6.0 | ||
| 2005-11 | 1.6 in FF 1.5 | ||
| 2006-10 | 1.7 in FF 2.0 | ||
| 2006-11 | 5.7 in IE 7.0 | ||
| 2008-10 | 1.8 in FF 3.0 | ||
| Sooner | 1.9 in FF 3.1 | 5.8 in IE 8.0 | |
| Later | 2.0 | 4 |
JavaScript is famous for its "client-side" use, i.e. on the user's browser.There are several major rendering engines or application frameworks (each used by one or more browsers), and each rendering engine has its own JavaScript engine. JavaScript may also be used on the "server-side" and other scenarios.
Except for the simplest of sites, it seems that the days are slipping when you could make a site with your own HTML, CSS, AJAX, and JavaScript on the client-side, plus whatever on the server-side. See http://www.surveymonkey.com/sr.aspx?sm=fXLiKcnKlD6cO5bRe961aBB6NCCWytRyY3rParAYmwA_3d. Now it seems that you have to use a library, as in the old build v buy argument. It's not simply for pretty stuff but for serious business stuff like data grids. They're calling them {AJAX | Widget | Web App} {Toolkits | Frameworks} these days. You can simply call them JavaScript libraries on the client-side, but on the server-side it's usually some other language generating JavaScript, CSS, and HTML for the client-side.
The top client-side JavaScript libraries are (in rough order):
The top server-side "JavaScript" libraries include:
There are libraries with more specific uses that are often included. Here are a few arbitrary ones:
Here are some miscellaneous items regarding JavaScript.
try ... catch ... finally and throw statements for error handling.VBS uses On Error and Next for error handling.Option Explicit feature of VBS.var, then JS assumes implicit variable declaration and that the variable is of the application/global scope.//This is a single line comment.
/* This is the start of a multi-line comment.
This is the end of a multi-line comment. */
<a> tag can call a JS function directly with this syntax: <a href="javascript:functionName()">.<script type="text/JavaScript">
<!-- //Hide script from no-script browsers.
Multiple lines of script may go here.
//End with a JS comment. -->
</script>
null==undefined; //auto type-conversion, so true null===undefined; //strict or no type-conversion, so false
+ operators, if either argument is a String or converts preferentially to one, then it does string concatenation, not numeric addition. Otherwise, if neither argument prefers to be a string, then it does numeric addition. (Short version: "+ is either string")>, >=, <, <= operators, if neither argument can be converted to a number, then it does string comparison, not numeric comparison. Otherwise, if at least one argument can be converted to a number, then it does numeric comparison. (Short version: "compare is neither number")==, != operators, first convert any Objects to their preferred primitive types. If the types are still different, convert any Boolean to a Number. If the types are still different, convert the non-Number argument to Number and compare as Numbers. Exception: null==undefined without any conversion defined.x = ( a+'' == b+'') //String comparison forced x = ( a -0 == b -0) //Number comparison forced x = ( !a == !b ) //Boolean comparison forced
if ( a != null) { ...} //may be buggy
if ( a ) { ...} //better
<img .... onmouseover="RunMe()">. VBS on the other hand can also handle event procedures by making procedures whose name follows this syntax: Object_Event(). Multiple JS statements can be included in the explicit event link.Page Modified: (Hand noted: 2008-03-17 22:30:42Z) (Auto noted: 2008-10-16 20:50:59Z)