JavaScript Playground - Run JS Code Online Free
Test JavaScript code instantly in your browser. Write, run, and debug JS with real-time console output. Perfect for learning, testing snippets, and quick prototyping.
Ctrl/Cmd + Enter to Run
Ctrl/Cmd + / to Comment
JavaScript Editor
Console Output
Console output will appear here...
Features
Instant Execution
Run JavaScript code instantly in your browser with no setup required.
Console Output
See console.log, errors, warnings, and info messages in real-time.
Syntax Highlighting
Clean monospace font with proper indentation support.
No Installation
Works entirely in your browser. No downloads or setup needed.
Example Code Snippets
Array Methods
const numbers = [1, 2, 3, 4, 5];
const doubled = numbers.map(n => n * 2);
const evens = numbers.filter(n => n % 2 === 0);
const sum = numbers.reduce((a, b) => a + b, 0);
console.log("Doubled:", doubled);
console.log("Evens:", evens);
console.log("Sum:", sum);Async/Await
async function fetchData() {
console.log("Fetching data...");
// Simulate API call
await new Promise(resolve =>
setTimeout(resolve, 1000)
);
console.log("Data fetched!");
return { id: 1, name: "John" };
}
fetchData().then(data =>
console.log("Result:", data)
);Object Manipulation
const user = {
name: "Alice",
age: 30,
city: "New York"
};
// Destructuring
const { name, age } = user;
console.log(name, age);
// Spread operator
const updated = { ...user, age: 31 };
console.log("Updated:", updated);Classes & Inheritance
class Animal {
constructor(name) {
this.name = name;
}
speak() {
console.log(`${this.name} makes a sound`);
}
}
class Dog extends Animal {
speak() {
console.log(`${this.name} barks`);
}
}
const dog = new Dog("Rex");
dog.speak();