JavaScript
A lightweight, interpreted, or just-in-time compiled programming language with first-class functions.
JavaScript (JS) is a high-level, interpreted, multi-paradigm programming language that conforms to the ECMAScript specification. It is one of the core technologies of the World Wide Web, alongside HTML and CSS, enabling dynamic and interactive content on websites. JavaScript code can be executed directly by web browsers (client-side scripting) or on servers using environments like Node.js (server-side scripting). Its architecture is event-driven and asynchronous, making it well-suited for handling user interactions and network requests without blocking the main execution thread. Key features include dynamic typing, prototype-based inheritance, first-class functions, and a rich standard library. The V8 JavaScript engine, developed by Google, is a prominent example of a high-performance JS engine used in Chrome and Node.js, employing Just-In-Time (JIT) compilation to improve execution speed. Trade-offs include its dynamic nature, which can lead to runtime errors that might be caught at compile time in statically-typed languages, and its single-threaded nature (though asynchronous patterns mitigate blocking). Modern JavaScript development often involves frameworks and libraries (e.g., React, Angular, Vue) to manage complexity and build sophisticated user interfaces.
graph LR
Center["JavaScript"]:::main
Rel_go_lang["go-lang"]:::related -.-> Center
click Rel_go_lang "/terms/go-lang"
Rel_assembly_language["assembly-language"]:::related -.-> Center
click Rel_assembly_language "/terms/assembly-language"
Rel_nodejs["nodejs"]:::related -.-> Center
click Rel_nodejs "/terms/nodejs"
classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
linkStyle default stroke:#4b5563,stroke-width:2px;
🧠 Knowledge Check
🧒 Explain Like I'm 5
The language that makes websites interactive. If HTML is the bone and CSS is the skin, JavaScript is the brain that makes things move and [react](/en/terms/react).
🤓 Expert Deep Dive
JavaScript's execution model is primarily single-threaded, utilizing an event [loop](/en/terms/event-loop) to handle asynchronous operations. The event loop continuously checks a message queue and executes callbacks when the call stack is empty. This allows non-blocking I/O operations, crucial for web applications. Modern JS engines (like V8) use JIT compilation, compiling JS code to machine code during runtime for performance gains. Prototype-based inheritance differs from class-based inheritance found in many other languages, offering flexibility but sometimes leading to confusion. The ECMAScript standard evolves annually, introducing new features like async/await, classes, and modules. Trade-offs include potential type coercion issues and the challenges of managing complex asynchronous flows (callback hell, though mitigated by Promises and async/await). Vulnerabilities can arise from insecure coding practices, such as cross-site scripting (XSS) if user input is not properly sanitized, or insecure direct object references when interacting with APIs.