JavaScript is a high-level, interpreted programming language that makes web pages interactive and dynamic. It is one of the core technologies of the web, along with HTML (structure) and CSS (style).
A high-level language is a human-readable programming language that uses English-like words.
An interpreted language runs code one line at a time using an interpreter, without needing to compile it first.
Single-threaded:
JavaScript runs on a single call stack, meaning it can only execute one task at a time.
Synchronous by default:
JavaScript executes code line by line, in order. Each operation must complete before the next one starts.
Asynchronous capabilities:
Even though it’s single-threaded, JavaScript uses the event loop and Web APIs to handle tasks like timers, API requests, and user interactions without blocking the main thread. This makes it feel "multi-tasking."
Multi-paradigm:
Supports object-oriented, functional, and event-driven programming styles.
// Object-oriented
class Person {
constructor(name) { this.name = name; }
greet() { console.log(`Hello, ${this.name}`); }
}
const p = new Person("Anik");
p.greet();
// Functional
const add = (a, b) => a + b;
console.log(add(2, 3));
// Event-driven example in browser
const button = document.createElement('button');
button.textContent = 'Click me';
document.body.appendChild(button);
button.addEventListener('click', () => {
alert('Hi there!');
});
Runs everywhere:
JavaScript is a single-threaded, synchronous (by default) programming language with powerful asynchronous features, designed to make web applications interactive, dynamic, and responsive.
let age = 25;
let pi = 3.14;.
let name = ‘John’;