














































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This exam targets individuals acting as architects in JavaScript-focused open-source environments under the OpenJS Foundation. It covers system design, modular JavaScript project architecture, NPM package governance, monorepo design patterns, dependency management, security auditing, CI/CD integration, semantic versioning strategies, and contribution workflows. Candidates must architect resilient, scalable solutions using JavaScript technologies and evaluate design trade-offs in real-world OSS ecosystem scenarios.
Typology: Exams
1 / 86
This page cannot be seen from the preview
Don't miss anything!















































































Question 1. Which Node.js global object provides a way to schedule a function to run after a specified delay? A) process B) setTimeout C) require D) Buffer Answer: B Explanation: setTimeout is a global function that invokes a callback after a given number of milliseconds. Question 2. In the CommonJS module system, which statement correctly exports a single function named handler? A) exports = handler; B) module.exports = handler; C) export default handler; D) exports.handler = handler; Answer: B Explanation: module.exports is the value returned by require; assigning the function directly exports it. Question 3. What does the fs.readFileSync method return when reading a text file without specifying an encoding? A) A string B) A Buffer object C) An ArrayBuffer D) Undefined Answer: B
Explanation: Without an encoding, readFileSync returns a Buffer containing the raw bytes. Question 4. Which of the following is the correct syntax for destructuring the url and method properties from a request object? A) const {url, method} = req; B) let [url, method] = req; C) var url = req.url, method = req.method; D) const url = req["url"], method = req["method"]; Answer: A Explanation: Object destructuring uses curly braces to extract named properties. Question 5. When using Promise.all, what happens if one of the promises rejects? A) The returned promise resolves with an array of results and errors. B) The returned promise rejects with the first rejection reason. C) All promises continue to run but the result is ignored. D) The function throws a synchronous error. Answer: B Explanation: Promise.all rejects immediately when any input promise rejects, propagating that reason. Question 6. Which method creates a readable stream from a file named data.txt? A) fs.createWriteStream('data.txt') B) fs.readFile('data.txt') C) fs.createReadStream('data.txt') D) fs.open('data.txt') Answer: C Explanation: fs.createReadStream returns a readable stream for the specified file.
Question 10. Which Node.js flag enables the inspector for debugging on port 9229? A) --inspect B) --debug C) --trace-warnings D) --harmony Answer: A Explanation: --inspect starts the V8 inspector listening on the default port 9229. Question 11. In an Express route, which method is used to send a JSON response? A) res.sendJSON() B) res.json() C) res.send() with a stringified object D) res.write() Answer: B Explanation: res.json() sets the appropriate header and stringifies the object automatically. Question 12. Which of the following is the correct way to spawn a child process that runs the ls - l command? A) child_process.exec('ls - l') B) child_process.spawn('ls', ['-l']) C) child_process.fork('ls - l') D) child_process.run('ls', ['-l']) Answer: B Explanation: spawn takes the command and an array of arguments, creating a streaming child process.
Question 13. What does the process.env.NODE_ENV variable typically control? A) The Node.js version. B) The environment mode (development, production). C) The operating system type. D) The current working directory. Answer: B Explanation: NODE_ENV is a convention used to indicate the runtime environment. Question 14. Which of the following statements about JavaScript closures is true? A) Closures can only be created inside classes. B) A closure captures the lexical environment at the time of function creation. C) Closures prevent garbage collection of all variables. D) Closures are exclusive to arrow functions. Answer: B Explanation: A closure retains references to variables from its defining scope. Question 15. In a Transform stream, which method must be implemented to modify incoming data? A) _write B) _read C) _transform D) _flush Answer: C Explanation: _transform receives chunks, processes them, and pushes transformed data downstream. Question 16. Which HTTP header is essential to mitigate Cross‑Site Scripting (XSS) attacks?
B) Append .catch() after the await. C) Use process.on('error'). D) Errors cannot be caught with await. Answer: A Explanation: await pauses execution; any rejection must be caught with try...catch. Question 20. In Node.js, what does the util.promisify function do? A) Converts a callback‑based function into one that returns a promise. B) Turns a promise into a callback style function. C) Generates a random UUID. D) Serializes an object to JSON. Answer: A Explanation: util.promisify wraps a function expecting a Node‑style callback and returns a promise‑based version. Question 21. Which of the following is the proper way to listen for the 'SIGINT' signal and exit gracefully? A) process.on('SIGINT', () => process.exit(0)); B) process.once('SIGINT', () => {}); C) process.emit('SIGINT'); D) process.kill('SIGINT'); Answer: A Explanation: Registering a listener on 'SIGINT' allows custom cleanup before calling process.exit. Question 22. What is the default encoding used by fs.writeFile when a string is supplied? A) utf8
B) ascii C) base64 D) binary Answer: A Explanation: Node defaults to UTF‑8 for string data unless another encoding is specified. Question 23. Which of the following Express middleware functions will log each incoming request method and URL? A) app.use((req, res, next) => { console.log(\${req.method} ${req.url}`); next(); });B)app.get((req, res) => { console.log(req.method); });C)app.use((req, res) => { console.log(req.headers); });D)app.all((req, res) => { console.log('Request'); });Answer: A Explanation: The middleware usesapp.useto run for all routes, logs method and URL, then callsnext(). **Question 24.** Which of the following statements about theBuffer.frommethod is correct? A) It creates a mutable string. B) It copies the data into a new Buffer from an array, string, or another Buffer. C) It only accepts hexadecimal strings. D) It returns a Uint8Array. Answer: B Explanation:Buffer.from` creates a new Buffer containing a copy of the supplied data. Question 25. In a RESTful API, which HTTP method is idempotent and typically used to replace a resource completely? A) POST
B) Object.defineProperty(obj, 'prop', { value: 10, readOnly: true }); C) Object.defineProperty(obj, 'prop', { get: () => 10 }); D) Object.defineProperty(obj, 'prop', { enumerable: false }); Answer: A Explanation: Setting writable: false makes the property non‑assignable after creation. Question 29. Which of the following npm scripts syntax runs the file server.js with Node and enables the inspector? A) "start": "node --inspect server.js" B) "start": "node - i server.js" C) "start": "node --debug server.js" D) "start": "node server.js --inspect" Answer: A Explanation: The --inspect flag must appear before the script file in the command. Question 30. In Express, which method would you use to serve static files from a directory named public? A) app.static('public') B) app.use(express.static('public')) C) app.get('/public', ...) D) app.route('public') Answer: B Explanation: express.static middleware serves files from the given root directory. Question 31. Which of the following is the correct way to catch unhandled promise rejections globally? A) process.on('unhandledRejection', handler);
B) process.on('uncaughtException', handler); C) process.on('rejectionHandled', handler); D) process.on('error', handler); Answer: A Explanation: The unhandledRejection event is emitted when a promise is rejected and no catch handler exists. Question 32. Which of the following is NOT a valid way to import a CommonJS module in an ES module file? A) import pkg from './pkg.cjs'; B) import * as pkg from './pkg.cjs'; C) import { something } from './pkg.cjs'; D) import pkg = require('./pkg.cjs'); Answer: D Explanation: import pkg = require() is TypeScript syntax, not valid in native ES modules. Question 33. Which HTTP header should be set to prevent browsers from caching sensitive JSON responses? A) Cache-Control: no-store B) Expires: 0 C) Pragma: no-cache D) ETag: "" Answer: A Explanation: Cache-Control: no-store instructs browsers not to store the response at all. Question 34. What does the os.totalmem() function return? A) The amount of free memory in bytes.
B) .cls C) .reset D) .clearConsole Answer: A Explanation: .clear is a REPL command that clears the current console view. Question 38. Which of the following is the correct way to create a read‑only property id on an object using a getter? A) Object.defineProperty(obj, 'id', { get: () => 5 }); B) Object.defineProperty(obj, 'id', { value: 5, writable: false }); C) obj.id = 5; Object.freeze(obj); D) Object.seal(obj); Answer: A Explanation: Defining only a get accessor makes the property effectively read‑only. Question 39. Which of the following NPM packages is commonly used for input validation in Express applications? A) lodash B) joi C) request D) chalk Answer: B Explanation: joi provides a rich schema‑based validation API. Question 40. In Node.js, which method of the process object can be used to schedule a callback to run after the current event loop turn? A) process.nextTick
B) process.setImmediate C) process.on('tick') D) process.defer Answer: A Explanation: process.nextTick queues a microtask to run after the current operation completes but before I/O events. Question 41. Which HTTP response header informs the client about the server’s supported content encoding algorithms? A) Accept-Encoding B) Content-Encoding C) Vary D) Transfer-Encoding Answer: B Explanation: Content-Encoding tells the client how the response body is encoded (e.g., gzip). Question 42. What does the stream.pipeline utility function do? A) It concatenates multiple streams into a single buffer. B) It automatically manages pipe errors and cleanup. C) It converts a readable stream into a writable one. D) It creates a new Transform stream. Answer: B Explanation: pipeline wires streams together and forwards errors, simplifying error handling. Question 43. Which of the following is the correct way to import the built‑in url module using ES module syntax? A) import url from 'url';
C) 0 (unlimited) D) 1 Answer: B Explanation: Node sets the default maxListeners to 10 to help detect potential memory leaks. Question 47. Which of these is the correct way to read a directory's contents asynchronously? A) fs.readdirSync(path, callback) B) fs.readdir(path, callback) C) fs.readDirectory(path, callback) D) fs.dir(path, callback) Answer: B Explanation: fs.readdir reads directory entries and invokes the callback with the results. Question 48. Which of the following is the most secure way to store a password in a Node.js application? A) Plain text in an environment variable. B) Base64‑encoded string in a config file. C) Hashed with bcrypt and stored in a database. D) Encrypted with AES and stored in memory. Answer: C Explanation: Bcrypt hashing (with salt) is the recommended approach for password storage. Question 49. What does the --max-old-space-size=4096 flag do when starting a Node.js process? A) Limits the heap to 4 GB. B) Sets the maximum number of open files.
C) Enables V8’s experimental garbage collector. D) Increases the stack size to 4 GB. Answer: A Explanation: The flag controls V8’s old generation heap size, limiting memory usage. Question 50. Which of the following is the correct way to add a route that matches any HTTP method for the path /ping in Express? A) app.all('/ping', handler); B) app.use('/ping', handler); C) app.route('/ping').all(handler); D) Both A and C are correct. Answer: D Explanation: app.all and app.route().all both register a handler for all methods on a path. Question 51. Which of the following statements about the fs.watch method is true? A) It provides reliable cross‑platform file change notifications. B) It uses native OS events and may emit duplicate events. C) It works only on Windows. D) It returns a promise. Answer: B Explanation: fs.watch relies on OS mechanisms and can produce duplicate or missed events on some platforms. Question 52. In a Node.js application, which module provides utilities for working with binary data in the form of fixed‑size sequences? A) stream B) buffer
B) setImmediate callbacks run before timers, process.nextTick runs after. C) process.nextTick runs before the event loop continues, setImmediate runs on the next tick of the poll phase. D) Both are equivalent and can be used interchangeably. Answer: C Explanation: nextTick executes before the event loop proceeds to the next phase; setImmediate runs later, during the check phase. Question 56. Which of the following is the correct way to export multiple named functions from a CommonJS module? A) module.exports = { foo, bar }; B) exports = { foo, bar }; C) export { foo, bar }; D) module.export = foo, bar; Answer: A Explanation: Assigning an object to module.exports exports the listed properties. Question 57. Which HTTP method is considered safe according to RFC 7231? A) POST B) PUT C) DELETE D) HEAD Answer: D Explanation: Safe methods do not modify server state; HEAD (like GET without a body) is safe.
Question 58. Which of the following is the correct way to create a child process that runs a separate Node.js script worker.js and communicates via IPC? A) child_process.fork('worker.js'); B) child_process.spawn('node', ['worker.js']); C) child_process.exec('node worker.js'); D) child_process.execFile('worker.js'); Answer: A Explanation: fork spawns a new Node process with an IPC channel for messaging. Question 59. Which of these NPM scripts will run the command npm run lint before executing node server.js? A) "start": "npm run lint && node server.js" B) "start": "node server.js && npm run lint" C) "start": "npm lint && node server.js" D) "start": "node server.js || npm run lint" Answer: A Explanation: Using && ensures node server.js runs only if npm run lint succeeds. Question 60. Which of the following is a recommended practice when handling large file uploads in Node.js? A) Load the entire file into memory before processing. B) Use a streaming parser such as busboy to process chunks. C) Convert the file to a base64 string and store it in a JSON object. D) Block the event loop until the upload finishes. Answer: B Explanation: Streaming parsers handle data piece‑by‑piece, avoiding memory exhaustion.