Bird
Raised Fist0
Denoframework~20 mins

Why Deno was created to fix Node.js mistakes - Challenge Your Understanding

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Deno Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why does Deno use secure defaults?
Deno was designed with security in mind. What is the main reason Deno requires explicit permission for file, network, or environment access?
ATo prevent accidental or malicious access to sensitive resources by default
BTo make the code run faster by limiting resource usage
CTo force developers to write more complex code
DTo ensure compatibility with older Node.js modules
Attempts:
2 left
💡 Hint
Think about what could happen if a program could access everything without asking.
❓ component_behavior
intermediate
2:00remaining
How does Deno handle module imports differently from Node.js?
Deno uses URLs for module imports instead of Node.js's package.json and node_modules system. What is a direct effect of this difference?
AModules are bundled into a single file automatically
BModules must be installed globally before use
CModules require a special configuration file like package.json
DModules can be imported directly from the web without a package manager
Attempts:
2 left
💡 Hint
Think about how you get code from the internet in Deno.
📝 Syntax
advanced
2:00remaining
What error does this Deno code produce?
Consider this Deno script run without any permissions:
const data = await Deno.readTextFile('secret.txt');
console.log(data);

What error will this code produce when run with deno run script.ts?
AReferenceError: Deno is not defined
BPermissionDenied: run again with --allow-read
CSyntaxError: Unexpected await outside async function
DFileNotFoundError: secret.txt does not exist
Attempts:
2 left
💡 Hint
Deno restricts file access by default.
🔧 Debug
advanced
2:00remaining
Why does this Node.js code cause a security risk that Deno avoids?
Node.js code:
const fs = require('fs');
const secret = fs.readFileSync('/etc/passwd', 'utf8');
console.log(secret);

Why is this a security risk in Node.js but not in Deno by default?
ANode.js runs code in a sandbox, Deno runs with full system access
BNode.js allows file system access without restrictions, Deno requires explicit permission
CNode.js blocks reading system files, Deno allows it
DNode.js encrypts files automatically, Deno does not
Attempts:
2 left
💡 Hint
Think about default access permissions in both runtimes.
❓ lifecycle
expert
3:00remaining
How does Deno's built-in tooling improve developer experience compared to Node.js?
Deno includes built-in tools like a formatter, linter, test runner, and bundler. What is a key advantage of this design over Node.js's approach?
ADevelopers do not need to install and configure multiple separate tools
BDeno automatically updates all dependencies without user input
CDeno compiles code to native machine code for faster execution
DDeno requires a special IDE to use these tools
Attempts:
2 left
💡 Hint
Think about how many tools you install separately in Node.js projects.

Practice

(1/5)
1. Why was Deno created as an improvement over Node.js?
easy
A. To make Node.js run faster without changes
B. To add support for older JavaScript versions
C. To fix security issues and simplify development
D. To remove TypeScript support completely

Solution

  1. Step 1: Understand Node.js limitations

    Node.js had security risks and complex setup issues that developers faced.
  2. Step 2: Identify Deno's goals

    Deno was designed to improve security and simplify the developer experience by default.
  3. Final Answer:

    To fix security issues and simplify development -> Option C
  4. Quick Check:

    Security and simplicity [OK]
Hint: Focus on security and simplicity as main goals [OK]
Common Mistakes:
  • Thinking Deno removes TypeScript support
  • Assuming Deno only speeds up Node.js
  • Believing Deno targets older JavaScript versions
2. Which of the following is the correct way to run a TypeScript file in Deno?
easy
A. deno run myfile.ts
B. node myfile.ts
C. deno compile myfile.js
D. node run myfile.js

Solution

  1. Step 1: Recall Deno's command for running scripts

    Deno runs TypeScript files directly using the command deno run filename.ts.
  2. Step 2: Check other options

    Node.js cannot run TypeScript files without compilation. deno compile myfile.js is for compiling, not running.
  3. Final Answer:

    deno run myfile.ts -> Option A
  4. Quick Check:

    Deno runs TS files with 'deno run' [OK]
Hint: Remember: Deno runs TS files directly with 'deno run' [OK]
Common Mistakes:
  • Using Node.js commands for TypeScript files
  • Confusing compile and run commands
  • Trying to run JavaScript files with Deno compile
3. What will be the output of this Deno script?
console.log(Deno.args.length);

when run with deno run script.ts one two?
medium
A. 0
B. undefined
C. 1
D. 2

Solution

  1. Step 1: Understand Deno.args

    Deno.args is an array of command-line arguments passed after the script name.
  2. Step 2: Count the arguments passed

    Running deno run script.ts one two passes two arguments: 'one' and 'two'.
  3. Final Answer:

    2 -> Option D
  4. Quick Check:

    Arguments count = 2 [OK]
Hint: Count arguments after script name in command line [OK]
Common Mistakes:
  • Counting script name as argument
  • Assuming no arguments passed
  • Confusing Deno.args with process.argv
4. Identify the error in this Deno script:
import { serve } from "https://deno.land/std/http/server.ts";

serve(() => new Response("Hello"));
medium
A. serve function requires a port number argument
B. Missing permission flag to allow network access
C. Incorrect import URL for Deno standard library
D. Response constructor is not valid in Deno

Solution

  1. Step 1: Check Deno's security model

    Deno requires explicit permission flags for network access when running scripts.
  2. Step 2: Analyze the script's network usage

    The script uses serve to start a server, which needs network permission.
  3. Final Answer:

    Missing permission flag to allow network access -> Option B
  4. Quick Check:

    Network access needs permission flag [OK]
Hint: Remember to add --allow-net for network scripts [OK]
Common Mistakes:
  • Assuming serve needs a port argument
  • Thinking import URL is incorrect
  • Believing Response is invalid in Deno
5. How does Deno improve security compared to Node.js when running scripts?
hard
A. By requiring explicit permission flags for file, network, and environment access
B. By disabling all network access permanently
C. By automatically sandboxing scripts without user control
D. By running scripts only in a browser environment

Solution

  1. Step 1: Understand Node.js security model

    Node.js allows scripts to access files, network, and environment without restrictions by default.
  2. Step 2: Identify Deno's security approach

    Deno requires users to explicitly grant permissions like --allow-net or --allow-read to scripts.
  3. Final Answer:

    By requiring explicit permission flags for file, network, and environment access -> Option A
  4. Quick Check:

    Explicit permission flags [OK]
Hint: Deno needs explicit permission flags for sensitive access [OK]
Common Mistakes:
  • Thinking Deno disables network permanently
  • Believing Deno auto-sandboxes without user input
  • Assuming Deno runs scripts only in browsers
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard