JavaScript is an interpreted scripting language created by
The current tendancy is to make a distinction between JavaScript, constituing the core language, and the DocumentObjectModel, providing a bunch of objects allowing to interact with its environnement.
In fact, JavaScript can be and is used in totally different environnements ( If I remember well, you can create scripts with it in the latest version of Photoshop, for example. )
Since you are likely to know Java, let's give a quick example:
Let's consider the following java class:
<code><font color="blue"> public class MyStuff { public final static String zeug="truc"; int value; MyStuff() { this(10); } MyStuff(int v) { value=v; } public int intenseComputation(int a,int b) { return a+b; } }In JavaScript 1.0, this would become something like:
<code><font color="blue"> function MyStuff(v) { if (MyStuff.arguments.length==0) v=10; this.value=v; this.intenseComputation=mystuff_intenseComputation; } MyStuff.zeug="truc"; function mystuff_intenseComputation(a,b) { return a+b; }
The main differences is that the constructor itself defines the field
and the methods of the object. Note that the mystuff_intenseComputation
is
defined in the global name space, which is not totally cool.
In JavaScript 1.1, you could modify it into
<code><font color="blue"> function MyStuff(v) { if (typeof v !="undefined") this.value=v; } MyStuff.zeug=truc; MyStuff.prototype.value=10; MyStuff.prototype.intenseComputation=my_stuff_intenseComputation;The change comes from the use of object prototyping.
And in JavaScript 1.2, you could replace the last line by
<code><font color="blue"> MyStuff.prototype.intenseComputation=function (a,b) { return a+b; }thus avoiding to pollute the global name space (by using lambda-functions and function affectation. )
Enough examples. Let's just say that JavaScript is much more dynamic than Java, has a very weak typing, and is, IMHO, very cool.
Guess who wrote the RFD for
JavaScript is cool. Learn Javascript.
-- MasonZhwiti (12/5/97)
-- Shameless propaganda by HenriTorgemane (12/9/97)
-- Pointless nitpicky formatting by DigiGod (5/18/98)
-- Ditto by GilbertHerschberger (7 October 1999)
Main.FileAttachment: | Action: | Size: | Date: | Who: | Comment: |
---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|