Skip to main content
Share Your Experience: Take the 2024 Developer Survey

JavaScript (not to be confused with Java) is a high-level, dynamic, multi-paradigm, weakly-typed language used for both client-side and server-side scripting. Use this tag for questions regarding common implementations of ECMAScript, JavaScript, JScript, etc. JS does not typically refer to its ECMA-cousin, ActionScript.

According to the language's creator Brendan Eich, his original inspiration for JavaScript was Scheme. A major requirement handed down to him from management was that the syntax be readily understood by Java developers. Originally called LiveScript, its name was eventually changed to "JavaScript". In all respects, other than sharing part of its name, JavaScript is very different from Java.

It is dynamically typed.

Unlike block-scoped languages the scope chain nests via objects and functions. Local vars declared inside a function will be accessible to the remainder of the function regardless of whether they were defined inside a loop or conditional statement. Nested objects and functions have access to local vars declared in ancestors via a native call object that is not exposed to JS.

It is a functional programming language featuring first class functions which can be passed around as data and applied to new contexts while maintaining links to their original environment execution context through closures. (i.e. a nested function with references to a parent function's local variables will hold on to those values when returned even after the parent function has completed execution)

It is a prototype-based OOP language. New properties can be added to the prototype property of object constructors (simply functions invoked with a 'new' keyword used to create objects with an initiation procedure) and objects that have already been instantiated will still inherit the new properties. Unlike class-based approaches, object constructors in JavaScript do not have the native ability to inherit from one another the way classes can inherit down from a series of super-classes. Such behavior is easily authored however.

Object literals (JSON, basically) are also available.

On the web, where it has seen the most use to date, JavaScript's primary role is to handle data on the client-side, communicate asynchronously with servers (AJAX), assign behavior to events, and allow dynamic manipulation of HTML and CSS through tight integration via the W3C DOM API.

Now with open source availability of JIT compiling engines like Google's V8, JavaScript is starting to spread into new territory though environment implementations like node.js, which allows scripting of JS in the context of file systems and server-side operations.

Code Language (used for syntax highlighting): lang-js