0
0
Node.jsframework~20 mins

How Node.js differs from browser JavaScript in Node.js - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Node.js vs Browser JavaScript Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Global Objects in Node.js vs Browser
Which global object is available in Node.js but NOT in browser JavaScript?
Aglobal
Bnavigator
Cwindow
Ddocument
Attempts:
2 left
💡 Hint
Think about the object that represents the global scope in Node.js.
component_behavior
intermediate
1:30remaining
File System Access in Node.js vs Browser
What happens if you try to use Node.js's 'fs' module in browser JavaScript?
AIt throws a ReferenceError because 'fs' is not defined
BIt works normally and reads files from the user's computer
CIt reads files but only from the browser cache
DIt prompts the user to select files manually
Attempts:
2 left
💡 Hint
Consider what modules are available in browsers by default.
📝 Syntax
advanced
2:00remaining
Using ES Modules in Node.js vs Browser
Which statement about ES Modules (import/export) in Node.js and browsers is correct?
ABrowsers do not support ES Modules natively
BBrowsers require .mjs extension for ES Modules to work
CNode.js does not support ES Modules at all
DNode.js supports ES Modules natively only if files have .mjs extension or 'type':'module' in package.json
Attempts:
2 left
💡 Hint
Think about how Node.js handles module types compared to browsers.
state_output
advanced
2:00remaining
Event Loop Behavior in Node.js vs Browser
What is a key difference in how the event loop handles timers in Node.js compared to browsers?
ABrowsers queue timers in the microtask queue, Node.js does not
BBrowsers execute timers immediately without delay, Node.js always delays
CNode.js uses separate phases for timers and I/O callbacks, browsers do not
DNode.js does not support setTimeout, browsers do
Attempts:
2 left
💡 Hint
Consider the phases of the Node.js event loop.
🔧 Debug
expert
2:30remaining
Identifying Error When Using Browser API in Node.js
What error will occur if you run this Node.js code? const element = document.getElementById('app'); console.log(element);
ATypeError: getElementById is not a function
BReferenceError: document is not defined
CSyntaxError: Unexpected identifier
DNo error, logs null
Attempts:
2 left
💡 Hint
Think about what 'document' means in Node.js.