Write, Run & Share Deno code online using OneCompiler's Deno online compiler for free. It's a modern, secure, and feature-rich runtime for JavaScript and TypeScript. Getting started with OneCompiler's Deno editor is easy and fast. The editor shows sample boilerplate code when you choose Deno as the language and start coding.
Deno is a secure runtime for JavaScript and TypeScript, built on V8 and Rust. It is designed by the creator of Node.js to improve upon its shortcomings, offering modern features with better security and developer experience.
- Secure by default: No file, network, or environment access unless explicitly granted.
- Built-in TypeScript support: No need for a separate compiler.
- Uses modern ES modules: No need for
package.json
ornode_modules
. - Ships with a built-in formatter, linter, and test runner.
- Supports Web APIs: Similar to browsers, Deno includes APIs like
fetch()
.
console.log("Hello, World!");
Keyword | Description | Scope |
---|---|---|
var |
Old way of declaring variables | Function or global |
let |
Block-scoped variable | Block scope |
const |
Constant, cannot be reassigned | Block scope |
Arrow functions provide a more concise syntax for defining functions.
const greet = (name: string): string => `Hello, ${name}!`;
console.log(greet("Deno"));
let name = "Deno";
console.log(`Hello, ${name}!`);
const message = `
Hello,
Welcome to Deno!
`;
console.log(message);
An array is a collection of values.
let numbers: number[] = [1, 2, 3, 4, 5];
console.log(numbers[0]); // Accessing first element
let moreNumbers = [...numbers, 6, 7, 8];
console.log(moreNumbers);
const user = { name: "Alice", age: 25 };
const { name, age } = user;
console.log(name, age);
for (let i = 0; i < 5; i++) {
console.log(i);
}
let count = 0;
while (count < 5) {
console.log(count);
count++;
}
let num = 0;
do {
console.log(num);
num++;
} while (num < 5);
Deno supports ES6 classes, allowing for object-oriented programming.
class Car {
model: string;
constructor(model: string) {
this.model = model;
}
showModel() {
console.log(`Car model: ${this.model}`);
}
}
const myCar = new Car("Tesla Model S");
myCar.showModel();
Deno is a modern and secure alternative to Node.js, offering built-in TypeScript support and a more streamlined developer experience. With its security-first approach and native ES module support, it is a great choice for modern JavaScript and TypeScript applications.