Java Script

JavaScript is a scripting language created by BrendanEich at Netscape that supports PrototypeBasedProgramming, Object OrientedProgramming?, and FunctionalProgramming. It was originally called LiveScript, but the name was changed to JavaScript for marketing reasons. Microsoft calls their version JScript. There is now a standardized version, EcmaScript [].

Some have claimed it is Lisp in C's clothing - - but being a dynamically-typed functional language is not enough to make something Lisp. JavaScript lacks many features that are crucial to Lisp; macros perhaps being at the top of the list. (Are macros crucial to Lisp? Or, just a great CLOS feature? (Macros *are not* a CLOS feature, they have little to do with CLOS, and actually, the other way round, quite a lot of CLOS would usually be expressed in terms of various macros.)) Perhaps JavaScript is a "dialect of Lisp" in Java's clothing. Or, JavaScript is Scheme in Java's clothing.

JavaScript is commonly found in WebBrowsers and servers. It can be embedded in HTML for both client-side and server-side processing. Recently, JavaScript has gained renewed interest for its RPC capabilities. See AjaxWebApplications.

On Windows systems, it can be used (along with VBScript) with the Microsoft WindowsScriptingHost as a system scripting language.

On Macs, it can be used as an OpenScriptingArchitecture language alongside AppleScript through the use of a plug-in (based on SpiderMonkey, see below). has two open-source implementations of JavaScript engines, one in Java (RhinoInterpreter, see and one in C (SpiderMonkey, see Both engines are embedded in a lot of products and also available for the command line.

It's also the basis for DynaScript?, the server-side scripting language for Sybase Dynamo (their answer to ASP).

Language Features

Unlike Java's inheritance model, JavaScript is prototype and slot based - sorta like NewtonScript and SelfLanguage. It is really quite neat! -- AnonymousDonor

I think some definitions of "object-oriented" are limited due to the nature of popular OO languages. I haven't used JavaScript directly, but I have used a prototypical language. The prototype is really just a delegate, which from a certain perspective is all that inheritance is, except that delegation is a run-time association between objects, while inheritance is compile time, therefore delegation is more flexible. Polymorphism can exist without inheritance. As a matter of fact, delegation promotes composition, which in turn promotes polymorphism. -- GregVaughn

I haven't tried this in JavaScript, but if it's truly Self-like, then you don't need to do name-mangling to accomplish inheritance. Instead, you adopt a Smalltalk-style metastructure as a matter of convention, including a process and method execution model. Then, by convention, every "prototype" delegates every method to its "class", which looks in its metaclass to see how to interpret it. Since delegation *is* inheritance, you'll get what you want.

JavaScript supports true LexicalClosures via function literals. A closure (also known as LambdaExpressions after LISP - where they probably originated) is simply an anonymous sub-routine that closes over the namespace of lexical variables within the scope of the block that defines the function body.

For some interesting use of closure-like behavior for JavaScript event callbacks, see BeyondJS [].

JavaScript is an interesting language. Arrays, objects, maps (AssociativeArray) are all unified. Members seem to be rather like slots in the SelfLanguage. The way objects can inherit from one another is very dynamic. I think you could do quite a slick UI framework for JavaScript. Yes, you could, and you might end up with something like MozillaXul.

MicroSoft are working on adding StaticTypeSafety support:


My friend NickSimons has got surprisingly passionate in favour of JavaScript as a pretty good object language in recent months. -- RichardDrake

Cross-platform compatibility

The AchillesHeel of JavaScript is its inconsistent behavior across the various platform/browser combinations. As a result, it is virtually impossible to use it to do anything robust on the client side. -- TomStambaugh

Yes, a big problem with writing JavaScript for the browser is the inconsistencies of its implementation across the various browsers. Take a look at my JsUnit. It's a unit testing framework for running JavaScript UnitTests inside the target browser. A nice side-effect of this is that you could run your tests in your target browsers. -- EdwardHieatt

Sorry, I can't agree at all. Ok, due to differences between the Explorer and Netscape versions there is some confusion. But I always try to write in unicode: one single version of a homepage for both. Period. Try looking at my page on French verbs conjugations - -- PieterJansegers

I disagree with the points about inconsistencies in implementation. If you say that about JavaScript then you must say the same thing about HTML. Netscape provides very good documentation on its DevEdge website and if you follow their guidelines then you will be able to write script that works in version 3 & 4 browsers (JavaScript 1.2) and version 5 browsers (JavaScript 1.5) with very very few problems.

The inconsistency problem manifests itself significantly in implementation of DHTML and DOM - particularly in version 4 browsers - but this can be overcome by writing an abstract API that either uses switching or the BridgePattern. JavaScript is actually a lot more flexible than is commonly believed. -- WalterRumsby

It is quite possible to write compatible code as long as you do not use the DocumentObjectModel (which is not part of the language definition anyway). Take a look at my JsUnit, which is available for a big number of environments as long as their engine is based on the ECMA standard. -- Jörg Schaible

In short, JavaScript suffers from a TightlyCoupledReputation problem (JavaScriptSucksInBrowsers).

JavaScript and Wiki

Is there some JavaScriptEnabledWiki? -- FridemarPache

Yes, check out Jeremy Ruston's TiddlyWiki ( - the original is stand-alone HTML with all logic implemented in JS. There're now several spin-offs using PHP/MySQL... -- KarstenSchmidt

Does anyone knows of any library (or way) that allows to write JavaScript CGIs? I'm planning on writing a WikiWikiWeb in JavaScript, I've found a really neat interpreter/byte-code compiler and it's a great way to learn the programming language (not the DOM/browser stuff)... Thanks! -- DavidDeLis

I may have misunderstood the question here, but if you use ASP you can use JScript to write server side code. -- TobinHarris

No, I meant JavaScript as an application building language, like C++ or Java, not as server-side stuff. I've written a small CGI library that allows me to access the query_string variables, but it's pretty weak, I'd prefer to work with one already done. Anyway... -- DavidDeLis

I am interested in using JavaScript and Wiki as a way of building a FilesystemBasedWiki or a WikiForLiterateProgramming. -- AndyGlew


Have you looked at the proposal of JavaScript 2.0? The ECMA TC39 group is working with the proposed draft at .#23You can find a lot of resources on JavaScript on the Mozilla project page as well...

Two compilers that translate JavaScript 2.0 to JavaScript 1.X are Jangaroo ( and Mascara (

Don't forget the Netscape JavaScript console - type javascript: into the URL field - better than dosument.write or alert() for tracing variables, etc. -- DaveEveritt

If used appropriately, JavaScript is an easy and effective tool for creating dynamic Web-based interfaces for proprietary Intranet applications.

As long as you have some form of defence against CrossSiteScriptingExposure, attacks from people outside who know what you're using inside.

I only found out about Wiki yesterday, but I have been using a guestbook which stores the updates in JavaScript function calls. My Web pages include these and I provide the code to be called.

This makes JavaScript really useful, as you can update the data on a page.

Have a look at (broken link: unhosted) and

I hoped that BTOpenworld would provide the guestbook script that saves JavaScript Function Calls along side their normal guestbook script, but I need help in working out how it would make them money.

It allows me to knock together simple applications quickly, and avoid a lot of the complications of server side programming.

From my limited knowledge of the PHP/MySQL solution, your database query gives you an array of the data from the database search. My idea gives you an array of data, it's just all the data that the guestbook users post in the order that they post the data.

It is similar to Wiki.

-- DougRice

A nice feature of JavaScript is its treatment of functions as first class objects, which allows Closures and HigherOrderFunctions.

For more information on JavaScript see:

Some JavaScript Tutorials


JavaScript is a ScriptingLanguage. See the definition at:

JavaScript enables you to write fixed menus easily and quickly--pull-down menus, windows, menus for the right click of the mouse and other things (given the right environment).

A non-programmer thinks, "For those who can't put together 3 lines of code in any language, javascript is god-send!" It's actually a product of Netscape and subsequent contributors and is JustAnotherProgrammingLanguage, though one shaped by its birth within the framework of a WebBrowser.

Paste the following as js.html in a local text file and open in your browser you can edit and run simple JavaScript code in the text field without refreshing (the button calls the eval() function). A simple ide for learning.

  <script language="JavaScript">
    function evaluate()
      //document.forms[0].out.value = 
      <input type="button" name="go" value="go" onClick="evaluate()"><p>
      <textarea rows="20" cols="40" name="field">
 //start code   

init(); o.m1(1);

function init() { o = new Object(); o.a1 = 0;

o.m1 = function(x) { alert("before:"+this.a1); this.a1 = x; alert("after:"+this.a1); } }

//end code </textarea> <textarea rows="20" cols="40" name="out"> </textarea> </form> </body> </html>

Some JavaScript oddities and bugaboos:

 if (a == b)
     var c = "Equal!";

if (c == "Equal!") { // do something }
is legal JavaScript. If the first condition is not true, c will evaluate to "undefined".

Some of the claims here may overstate the power of JavaScript. While the language itself may, given an ideal engine in an ideal environment, provide everything mentioned, there are still important shortcomings that need to be addressed before a JavaScriptIde can be competitive with Smalltalk (my benchmark).

In particular, what if any execution model is implied by the language, and how much of that model can be surfaced in the environment? Can I get at things comparable to stack frames, activation records, and so on? Is there a real process model (real in the sense that I can do multi-threaded things)?

How hard would it be to support a basic Smalltalk-style debugger/inspector? I note, for example, that the VenkmanDebugger cuts several corners, and appears to dramatically slow the execution while running. Is Venkman the best there is? Is Venkman itself written in JavaScript, so that I can change it on the fly?

[The short answer is no. The EcmaScript language standard itself is minimal and doesn't specify anything about threading or processes or even an execution model. It is intended to be extended, though, so an implementation of JavaScript with these features certainly would be possible. Venkman, as with all XUL applications, is implemented in JavaScript but I believe the JS engine that powers the application is separate from the JS engine that executes the code Venkman looks at (and the JS code that runs on web pages).]

DouglasCrockford has articles about how to use JavaScript in an object-oriented fashion at He also has an article called JavaScript: The World's Most Misunderstood Programming Language that I like a lot. -- ChadSkeeters

JavaScript QuickQuestions

Q Serverside Javascripts on Microsoft IIS. Any benefits to using it instead of VbScript?

Answer: Yes, you can share function and code snippets that can be used on both the server and client side, like form validation, error checking (but not handling), or other more complex algorithms, like regex's.

That, and VbScript sucks in comparison. It doesn't have exception handling, anonymous functions, prototypes, or a good culture in general.

Question: Any recomendations on books? Something like JavaScriptForProgrammers?, not JavaScriptForTotalMorons?, please.

Answer: Check out the book list on IwannaLearnJavaScript.

Question: Is there any mechanism for JavaScript to communicate information between frames and windows in a browser? (e.g. like 'cookies' for JavaScript, but NOT delivered as part of the HTTP request header? - i.e. kept purely client-side?)

Answer: Yes. When a frame named frame1 wants to access a frame named frame2, it can do so via parent.frame2. See, e.g., the "Writing to Other Frames and Windows" section of DynamicHtmlTheDefinitiveReference? from OreillyAndAssociates.

Question: That does not seem very cookie-like, since the communication requires knowing ahead of time (by name) exactly which other frames and windows will be involved in the communication. Is there a way to do this Can one do it without knowing the 'names' of these other windows and frames? (My goal is HmacUserAuthentication for WikiIde, and this would just make it convenient by automatically logging in on all pages by entering username and password on one page.)

See EcmaScript, JavaScriptRocks, JavaScriptSucks, JavaScriptCodingStandard, OpenSourceJavaScript, JavaScriptEnabledWiki, WikiWithProgrammableContent, VisualJavaScript, JavaScriptObjectNotation(JSON)

CategoryProgrammingLanguage CategoryJavaScript CategoryWebDesign CategoryPrototypeProgramming

EditText of this page (last edited May 7, 2014) or FindPage with title or text search