JavaScript is a lightweight, interpreted programming language with first-class functions. It is the only programming language that runs natively in all major web browsers, making it the language of the web. JavaScript adds interactivity, animations, and dynamic behaviour to HTML pages. Thanks to Node.js, it also runs on servers, making it the only language that covers both front-end and back-end development.
Need to format or beautify a JavaScript file?
Open JavaScript Formatter →JavaScript was created by Brendan Eich at Netscape in just 10 days in May 1995. It was originally called Mocha, then LiveScript, before being renamed JavaScript — a marketing decision to capitalise on the popularity of Sun's Java language. Despite the name similarity, the two languages are unrelated. JavaScript was standardised as ECMAScript (ES) by Ecma International in 1997. Major milestones include ES5 (2009), ES6/ES2015 (2015 — the biggest update in language history), and annual releases from ES2016 onwards.
JavaScript is dynamically typed: variables can hold any type of value and types are checked at runtime. Modern JavaScript uses let and const for variable declarations. Functions are first-class values and can be assigned to variables, passed as arguments, and returned from other functions.
// Variables
const name = "Alice";
let age = 30;
// Function
function greet(person) {
return `Hello, ${person}!`;
}
// Arrow function
const square = (n) => n * n;
// Array methods
const numbers = [1, 2, 3, 4, 5];
const doubled = numbers.map(n => n * 2); // [2, 4, 6, 8, 10]
const evens = numbers.filter(n => n % 2 === 0); // [2, 4]
// Async / Await
async function fetchUser(id) {
const response = await fetch(`/api/users/${id}`);
const data = await response.json();
return data;
}
JavaScript has eight data types — seven primitives and one object type:
"hello", 'world', `template ${literal}`42, 3.14, NaN, Infinity9007199254740991ntrue or falsenullimport / export) allow splitting code into reusable filesDespite the similar name, JavaScript and Java are completely different languages:
TypeScript is a superset of JavaScript developed by Microsoft that compiles to plain JavaScript:
const by default; use let when the variable needs to be reassigned. Avoid var.=== checks both value and type; == performs type coercion — prefer ===typeof null returns "object" — a historical bug in the languagetypeof [] returns "object"; use Array.isArray() to checkJavaScript is a lightweight, interpreted programming language with first-class functions. It is the only programming language that runs natively in web browsers and is used to add interactivity, animations, and dynamic behaviour to web pages. It can also run on servers via Node.js.
JavaScript is used for interactive web pages (form validation, animations, DOM manipulation), single-page applications (React, Vue, Angular), server-side development (Node.js), mobile apps (React Native), desktop apps (Electron), and browser extensions.
No. JavaScript and Java are completely different languages that share only a similar name. Java is a compiled, statically typed, object-oriented language. JavaScript is interpreted, dynamically typed, and was originally designed for browser scripting.
TypeScript is a superset of JavaScript developed by Microsoft that adds optional static typing. TypeScript code compiles to plain JavaScript. All JavaScript code is valid TypeScript, but TypeScript adds type annotations, interfaces and generics that help catch bugs at compile time.
Both. JavaScript originally ran only in browsers (front-end). With Node.js (2009), JavaScript can now also run on servers (back-end). This makes JavaScript the only language that can be used for both front-end and back-end development.
JavaScript has a relatively low barrier to entry — you only need a browser to start. Basic concepts like variables, loops, and functions are straightforward. However, async programming, the event loop, prototypal inheritance, and framework ecosystems take time to master.