📖 Scenario: You are learning about modern JavaScript runtimes. Node.js was popular but had some issues. Deno was created to fix those problems and improve the developer experience.
🎯 Goal: Build a simple Deno script that shows how Deno improves on Node.js by using secure permissions and modern module imports.
📋 What You'll Learn
Create a Deno script with a list of URLs to fetch data from
Add a configuration variable to control if the script runs in secure mode
Use a loop to fetch data from each URL using Deno's fetch API
Add a final line to print a message about permission usage
💡 Why This Matters
🌍 Real World
Deno was created to fix Node.js issues like security and module management. This project shows how Deno scripts use secure permissions and modern JavaScript features.
💼 Career
Understanding Deno helps developers write safer, modern server-side JavaScript. Many companies look for skills in new runtimes that improve developer experience and security.
Progress0 / 4 steps
1
DATA SETUP: Create a list of URLs
Create a variable called urls that is an array containing these exact strings: "https://deno.land", "https://nodejs.org", and "https://example.com".
Deno
Hint
Use const to declare an array named urls with the exact URLs as strings.
2
CONFIGURATION: Add a secure mode flag
Create a boolean variable called secureMode and set it to true to represent running the script with secure permissions.
Deno
Hint
Use const to declare secureMode and assign it the value true.
3
CORE LOGIC: Fetch data from each URL
Use a for loop with variable url to iterate over urls. Inside the loop, use await fetch(url) to get the response and store it in a variable called response.
Deno
Hint
Use for (const url of urls) and inside it use const response = await fetch(url).
4
COMPLETION: Print permission usage message
Add a line after the loop that uses console.log to print the exact message: "Running in secure mode: true" using the secureMode variable.
Deno
Hint
Use console.log with a template string to show the message including secureMode.
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
Step 1: Understand Node.js limitations
Node.js had security risks and complex setup issues that developers faced.
Step 2: Identify Deno's goals
Deno was designed to improve security and simplify the developer experience by default.
Final Answer:
To fix security issues and simplify development -> Option C
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
Step 1: Recall Deno's command for running scripts
Deno runs TypeScript files directly using the command deno run filename.ts.
Step 2: Check other options
Node.js cannot run TypeScript files without compilation. deno compile myfile.js is for compiling, not running.