</>
CompilerOnline
Open Interactive Editor

Online JavaScript Compiler

Introduction to JavaScript

JavaScript is a high-level, dynamic, single-threaded programming language. It is the language of the web, powering interactive client-side browser features and server-side runtime environments like Node.js. Initially created in 10 days by Brendan Eich in 1995, it has evolved into a fully-featured language standardized as ECMAScript.

JavaScript runs on a single main thread, using an event loop and asynchronous callbacks to handle tasks like network requests and user interactions without freezing the user interface.

This asynchronous nature is a core design feature of JavaScript, enabling high concurrency on servers. On our compiler, JavaScript executes on a Node.js server inside a Docker sandbox, granting access to modern ECMAScript features and terminal log outputs.

JavaScript is a prototype-based language, which means inheritance is achieved through prototypes rather than classical classes, though the modern class syntax makes OOP look familiar to developers coming from Java or C++.

Asynchronous Callbacks

Because JavaScript is single-threaded, functions that take time to run (like timeouts, file operations, or API calls) accept callback functions that are executed once the task finishes, without blocking other scripts.

javascript
function delayedMessage(msg) {
    setTimeout(() => console.log("Callback:", msg), 300);
}
delayedMessage("Hello from Timeout Callback!");
javascript
console.log("JavaScript Sandbox Initialized.");
const date = new Date();
console.log("Current system time:", date.toDateString());