Home   Info   DevZone   Wiki  
UsersWeb  |  MainWeb  |  InfoWeb  |  DevZoneWeb  |  SupportWeb
JavaScript ] [ not logged in ] [ Web: Imported ] goto:  options
[ get info on or edit ] login or new user ] [ list of topics, hubs & nodes, or recent changes ]

In a Nutshell

JavaScript is an interpreted scripting language created by NetscapeCommunications. It only slightly resembles Java, in its object-oriented nature (though limited). However, it can help to glue HTML and Java applets together so it has some merit. In addition, it has become the standard way to add simple interactivity to a web page.

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. )

An 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.

What's in a Name?

It was originally named LiveScript, until Netscape partnered more closely with Sun and changed the name to JavaScript (some people think this was a poor decision because it confuses too many users between the two very different languages). Microsoft implements a nearly compatible version in its own "JScript."

Links

Trivia

Guess who wrote the RFD for comp.lang.javascript? It was me! Muhahahaha!!!

Advice

JavaScript is cool. Learn Javascript.

Contributors

-- 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:
PUBURL/icn/else.gif" width="16" hight="16" align="top"> PUBURL/%WEB%/TOPIC/FSE.txt">FSE.txt WEB/%TOPIC%?filename=FSE.txt">view WEB/%TOPIC%?filename=FSE.txt">update 8523 03 Oct 100 - 09:02 Main.TWikiGuest dsafdsfds
PUBURL/icn/else.gif" width="16" hight="16" align="top"> PUBURL/%WEB%/TOPIC/test.txt">test.txt WEB/%TOPIC%?filename=test.txt">view WEB/%TOPIC%?filename=test.txt">update 4712 07 Sep 100 - 14:42 Main.TWikiGuest test
PUBURL/icn/else.gif" width="16" hight="16" align="top"> PUBURL/%WEB%/TOPIC/wikiHome.gif">wikiHome.gif WEB/%TOPIC%?filename=wikiHome.gif">view WEB/%TOPIC%?filename=wikiHome.gif">update 4560 31 Jan 101 - 19:00 Main.TWikiGuest
WEB/%TOPIC%">add



Content of these pages are owned and copyrighted by the poster.
Hosted by: