Deno is a modern runtime for JavaScript and TypeScript that focuses on security, simplicity, and modern features.
Click to reveal answer
intermediate
How does Deno handle security compared to Node.js?
Deno runs code in a secure sandbox by default, requiring explicit permission for file, network, or environment access. Node.js does not have this by default.
Click to reveal answer
intermediate
Which module system does Deno use?
Deno uses ES Modules with URLs or local paths and does not use a package manager like npm. Node.js uses CommonJS modules and npm for packages.
Click to reveal answer
intermediate
How does Deno simplify dependency management?
Deno imports dependencies directly via URLs and caches them, removing the need for a separate package manager like npm.
Click to reveal answer
intermediate
What built-in features does Deno provide that Node.js requires external tools for?
Deno includes a built-in formatter, linter, test runner, and supports TypeScript out of the box, while Node.js requires separate tools for these.
Click to reveal answer
Which runtime has built-in TypeScript support without extra setup?
ADeno
BNode.js
CBoth
DNeither
✗ Incorrect
Deno supports TypeScript natively, while Node.js requires additional tools like ts-node or transpilers.
How does Deno handle package management?
AImports modules via URLs
BUses yarn
CUses npm
DNo modules supported
✗ Incorrect
Deno imports modules directly from URLs or local files, without a package manager like npm.
Which runtime requires explicit permission to access files or network by default?
ANeither
BNode.js
CBoth
DDeno
✗ Incorrect
Deno runs code in a secure sandbox and requires permissions for file, network, or environment access.
Which module system is primarily used by Node.js?
AES Modules
BCommonJS
CAMD
DUMD
✗ Incorrect
Node.js primarily uses CommonJS modules, though it supports ES Modules with configuration.
Which runtime includes a built-in test runner?
ANode.js
BNeither
CDeno
DBoth
✗ Incorrect
Deno includes a built-in test runner, while Node.js requires external libraries like Jest or Mocha.
Explain the main security differences between Deno and Node.js.
Think about how each runtime controls access to files and network.
You got /3 concepts.
Describe how dependency management differs between Deno and Node.js.
Consider how each runtime finds and uses external code.
You got /4 concepts.
Practice
(1/5)
1. Which of the following is a key security feature of Deno compared to Node.js?
easy
A. Node.js has built-in sandboxing for all scripts.
B. Deno allows all file and network access without restrictions.
C. Deno runs code with restricted permissions by default.
D. Node.js requires explicit permission flags for network access.
Solution
Step 1: Understand Deno's default security model
Deno runs scripts with no file, network, or environment access unless explicitly allowed.
Step 2: Compare with Node.js default behavior
Node.js allows full access by default without permission restrictions.
Final Answer:
Deno runs code with restricted permissions by default. -> Option C
Quick Check:
Deno security = restricted by default [OK]
Hint: Remember: Deno locks down access unless you say otherwise [OK]
Common Mistakes:
Thinking Node.js restricts permissions by default
Assuming Deno allows all access without flags
Confusing Node.js and Deno security models
2. Which syntax correctly runs a Deno script with network access permission?
easy
A. deno run --allow-net script.ts
B. node run --allow-net script.ts
C. deno run script.ts --allow-net
D. node run script.ts --allow-net
Solution
Step 1: Recall Deno command structure
Deno uses deno run followed by permission flags before the script name.
Step 2: Identify correct flag placement
The flag --allow-net must come before the script file name.
Final Answer:
deno run --allow-net script.ts -> Option A
Quick Check:
Deno run + flags before script [OK]
Hint: Flags come before script name in Deno commands [OK]
Common Mistakes:
Placing flags after the script name
Using Node.js commands for Deno
Mixing up 'node' and 'deno' commands
3. What will the following Deno code output if run without any permission flags?
console.log("Reading file...");
const data = await Deno.readTextFile("example.txt");
console.log(data);
medium
A. PermissionDenied: read access to 'example.txt' is not allowed
B. Contents of example.txt printed
C. SyntaxError due to await outside async function
D. FileNotFoundError if example.txt does not exist
Solution
Step 1: Check permission requirements for file reading
Deno requires explicit --allow-read permission to read files.
Step 2: Analyze code run without permissions
Running without --allow-read causes a PermissionDenied error when reading a file.
Final Answer:
PermissionDenied: read access to 'example.txt' is not allowed -> Option A
Quick Check:
Deno file read needs permission [OK]
Hint: Deno blocks file reads without --allow-read flag [OK]
Common Mistakes:
Assuming file reads work without permission
Confusing syntax errors with permission errors
Ignoring Deno's security model
4. Identify the error in this Node.js code snippet compared to Deno's approach:
import { serve } from "https://deno.land/std/http/server.ts";
serve(() => new Response("Hello"));
medium
A. Node.js needs the 'serve' function to be called with 'new'.
B. Node.js cannot import modules directly from URLs like Deno.
C. Node.js does not support async functions.
D. Node.js requires 'require' instead of 'import'.
Solution
Step 1: Understand module import differences
Deno supports direct URL imports; Node.js does not support this natively.
Step 2: Identify Node.js module system
Node.js uses local files or npm packages, not direct URL imports.
Final Answer:
Node.js cannot import modules directly from URLs like Deno. -> Option B
Quick Check:
Node.js import URL support = no [OK]
Hint: Node.js needs local or npm modules, not URL imports [OK]
Common Mistakes:
Thinking Node.js supports URL imports
Confusing import syntax with async support
Assuming 'new' is needed for serve function
5. You want to build a secure web server that only allows network access and no file system access. Which setup best fits this requirement using Deno and Node.js?
hard
A. Use Node.js with node --allow-net server.js to restrict file access.
B. Use Node.js with node server.js and rely on default security.
C. Use Deno with deno run server.ts without flags to allow all access.
D. Use Deno with deno run --allow-net server.ts to restrict file access.
Solution
Step 1: Identify security needs
The server should allow only network access, no file system access.
Step 2: Compare Deno and Node.js permission models
Deno allows fine-grained permission control via flags; Node.js does not restrict by default.
Step 3: Choose correct command
deno run --allow-net server.ts grants network access only, blocking file system access.
Final Answer:
Use Deno with deno run --allow-net server.ts to restrict file access. -> Option D
Quick Check:
Deno permission flags enable precise access control [OK]
Hint: Deno flags control access; Node.js lacks default restrictions [OK]
Common Mistakes:
Assuming Node.js restricts access by default
Using Deno without flags allows no permissions
Thinking Node.js supports --allow-net flag
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.