Node.js - URL and Query String HandlingWhy does the URL constructor in Node.js require a base URL when given a relative path?ATo resolve the relative path into a full absolute URLBBecause relative paths are invalid in URLsCTo validate the syntax of the relative pathDTo convert the relative path into a file system pathCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand purpose of base URLThe base URL provides context to convert a relative path into a full absolute URL.Step 2: Clarify why base is neededWithout a base, the relative path cannot be resolved to a complete URL string.Final Answer:To resolve the relative path into a full absolute URL -> Option AQuick Check:Base URL resolves relative paths = A [OK]Quick Trick: Base URL needed to make relative path absolute [OK]Common Mistakes:Thinking relative paths are invalid aloneConfusing URL resolution with file system paths
Master "URL and Query String Handling" in Node.js9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More Node.js Quizzes Child Processes - spawn for streaming processes - Quiz 9hard Cluster Module - Why clustering matters for performance - Quiz 6medium Debugging and Profiling - Console methods beyond log - Quiz 10hard Error Handling Patterns - Error-first callback convention - Quiz 10hard Error Handling Patterns - Centralized error handling - Quiz 9hard Error Handling Patterns - Custom error classes - Quiz 8hard Error Handling Patterns - Unhandled rejection handling - Quiz 1easy Timers and Scheduling - setInterval and clearInterval - Quiz 6medium Worker Threads - SharedArrayBuffer for shared memory - Quiz 10hard Worker Threads - Worker thread vs child process - Quiz 11easy