JavaScript is a high-level programming language most commonly used for client-side scripting in the web browser. The language uses dynamic and weak typing, and provides support for several programming paradigms, including prototype-based object-oriented programming.

JavaScript engines are used to translate and execute code, traditionally using interpretation. Some more recent engines, such as Google Chrome's V8, instead compile the JavaScript to machine code before execution for significant performance gains.

Although they share a similar name, JavaScript actually has very little to do with the Java programming language. When named, JavaScript was intended to complement Java as a scripting language, but it has since become a distinct programming language of its own right. JavaScript is now a dialect of the EMCAScript scripting language standard, along with others such as JScript and ActionScript.


Programming Paradigms

JavaScript uses a C-based syntax, allowing for imperative and structured programming styles. It also has several features that can be useful for functional programming, such as first-class functions and closures.

Whilst JavaScript does provide support for object-oriented programming, it uses a prototype-based style rather than the normal class-based style. An object will inherit methods and properties from its prototype, which is just another object. When a property is accessed, the initial object is first searched for the property. If it is not found, its prototype is then searched for the property, and then the prototype object's prototype, and so on. The prototype chain is traversed upwards until the property is found or 'Object' is reached. If the property is not found, it will evaluate to 'undefined' rather than causing an error.


JavaScript uses dynamic typing, meaning a variable can hold a value of any type regardless of what values and types it has previously held. It also uses weak typing, allowing implicit type conversions. For example, to evaluate operations between a string and a number, JavaScript will silently attempt to convert the string to a number or vice versa instead of throwing an error.

A demonstration of JavaScript's weak typing in Google Chrome's console:

> 5 * "3"
> "abc" + 1
> "abc" / 4
> 1 / 0
> [1, 2, 3][17]


JavaScript was designed to be a client-side scripting language in web browsers, providing a means for interaction with the user and the manipulation of the Document Object Model (DOM). This has always been JavaScript's most common application, but the language has recently seen a huge increase in use outside of the browser.

JavaScript is often used for desktop widgets and simple applications. HTML5 applications are becoming increasingly popular, largely due to their ability to run on most devices, including smartphones and tablets. Operating Systems are beginning to integrate these JavaScript based applications so that a web browser is not needed. This is the case with Windows 8 and, to an even further extent, Firefox OS.

JavaScript can also be used for server-side scripting through platforms like Node.js. Using the same language on both the client-side and server-side has many advantages.

Some applications, such as Unity and Adobe Photoshop, use JavaScript as a scripting language. Most modern browsers also allow additional functionality to be added through extensions in JavaScript.


Hello World

A simple "Hello world" program in JavaScript:

alert("Hello, world!");

Alternatively, the console can be used to display output:

console.log("Hello, world!");


Using an immediately-invoked function expression and closures to create a counter object:

var counter = (function() {
    var privateString = "Hi";
    var n = 0;
    return {
        increment: function() {
        output: function() {

DOM Manipulation

An example that changes the location of each link on the page:

var links = document.getElementsByTagName("a");
for (var i = 0; i < links.length; i++) {
    links[i].href = "";


QR Code
QR Code javascript (generated for current page)