












































































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 focuses on Dojo framework knowledge, including reactive programming concepts, widget authoring, state management, rendering lifecycles, routing, and TypeScript integration. Practical assessments simulate real-world application architecture patterns, modular UI development, and contribution workflows within the OpenJS Dojo ecosystem.
Typology: Exams
1 / 84
This page cannot be seen from the preview
Don't miss anything!













































































Question 1. In JavaScript, which operator checks for both value and type equality? A) == B) != C) === D) !== Answer: C Explanation: The strict equality operator (===) returns true only if both the value and the type are identical. Question 2. Which of the following correctly creates a Promise that resolves with the value 42? A) new Promise((res, rej) => { res(42); }) B) Promise.resolve(42) C) await 42 D) Both A and B Answer: D Explanation: Both the explicit constructor and Promise.resolve produce a Promise that resolves to 42. Question 3. What does the await keyword do inside an async function? A) Pauses the entire JavaScript thread until the Promise settles. B) Converts a non‑Promise value into a rejected Promise. C) Waits for the Promise to settle and returns its fulfilled value or throws its rejection. D) Creates a new Promise automatically. Answer: C Explanation: await pauses the async function, not the event loop, and returns the resolved value or throws the error.
Question 4. In the Node.js event‑loop, which phase handles callbacks from setImmediate? A) Timers B) I/O callbacks C) Check D) Close callbacks Answer: C Explanation: The check phase processes callbacks scheduled by setImmediate. Question 5. Which syntax correctly uses destructuring to extract a and b from an object {a:1,b:2}? A) let {a,b} = {a:1,b:2}; B) let [a,b] = {a:1,b:2}; C) let {a;b} = {a:1,b:2}; D) let a,b = {a:1,b:2}; Answer: A Explanation: Object destructuring uses curly braces and matches property names. Question 6. Arrow functions differ from regular functions in that they: A) Have their own this binding. B) Cannot be used as constructors. C) Have a prototype property. D) All of the above. Answer: B Explanation: Arrow functions inherit this from the surrounding scope and cannot be called with new.
A) --inspect B) --debug C) --trace-warnings D) --harmony Answer: A Explanation: node --inspect starts the debugger and opens the inspector protocol. Question 11. The -r flag in the Node.js CLI is used to: A) Run a script file. B) Preload a module before the entry point. C) Enable strict mode. D) Display the current working directory. Answer: B Explanation: -r <module> loads the specified module before the main script. Question 12. Which statement about CommonJS modules is true? A) They use import/export. B) They are resolved synchronously. C) They support top‑level await. D) They are only available in browsers. Answer: B Explanation: require() loads modules synchronously at runtime. Question 13. In an ES module, which syntax correctly imports the default export from utils.js? A) import utils from './utils.js';
B) import {default as utils} from './utils.js'; C) require('./utils.js'); D) Both A and B Answer: D Explanation: Both forms import the default export; the second uses a named import alias. Question 14. When Node resolves a module name, which folder is consulted first? A) node_modules in the current directory. B) The global npm folder. C) The parent directory’s node_modules. D) The system’s PATH. Answer: A Explanation: Node starts resolution from the directory of the requesting file and looks for node_modules there. Question 15. Which field in package.json defines the command to run when the package is installed globally? A) scripts.start B) bin C) main D) engines Answer: B Explanation: The bin field maps command names to executable files for global installs. Question 16. A dependency listed under devDependencies is: A) Installed when running npm install --production. B) Excluded from production builds by default.
C) buf.encode('base64') D) Buffer.base64Encode(buf) Answer: A Explanation: toString accepts an encoding argument; 'base64' produces a Base representation. Question 20. Which stream event indicates that a Readable stream has no more data to provide? A) data B) end C) close D) finish Answer: B Explanation: The end event fires when the stream has emitted all data. Question 21. In a Writable stream, what does the drain event signify? A) The internal buffer is empty and can accept more data. B) The stream has finished writing and closed. C) An error occurred during write. D) The stream is paused. Answer: A Explanation: drain is emitted when the write buffer empties after backpressure. Question 22. Which of the following is a Transform stream? A) fs.createReadStream() B) fs.createWriteStream() C) zlib.createGzip()
D) net.Socket() Answer: C Explanation: zlib.createGzip() both reads and writes, modifying data on the fly. Question 23. The pipeline utility from stream module is preferred over manual piping because it: A) Automatically sets object mode. B) Provides built‑in error propagation and cleanup. C) Converts streams to promises. D) Enables parallel execution of streams. Answer: B Explanation: pipeline forwards errors and closes all streams safely. Question 24. Which method on an EventEmitter removes a specific listener? A) off B) removeListener C) unregister D) Both A and B (Node v10+) Answer: D Explanation: off is an alias for removeListener introduced in recent Node versions. Question 25. What does the once method on an EventEmitter do? A) Registers a listener that is invoked every time the event occurs. B) Registers a listener that is invoked only the first time the event occurs. C) Registers a listener that cannot be removed. D) Registers a listener that runs in a separate thread.
Explanation: The Sync suffix indicates a blocking, synchronous call. Question 29. Which fs method returns a Promise for reading a file? A) fs.readFile B) fs.readFileSync C) fs.promises.readFile D) fs.createReadStream Answer: C Explanation: The fs.promises API provides promise‑based versions of file‑system functions. Question 30. What does fs.watch emit when a file is modified? A) change event with filename and event type. B) rename event only. C) modify event. D) No event; you must poll. Answer: A Explanation: fs.watch emits a change event with details about the operation. Question 31. Which path method resolves a sequence of path segments into an absolute path? A) path.join B) path.normalize C) path.resolve D) path.relative Answer: C Explanation: path.resolve processes arguments from right to left, returning an absolute path.
Question 32. Accessing process.env.NODE_ENV returns: A) The current working directory. B) The value of the environment variable NODE_ENV. C) The Node.js version. D) The PID of the process. Answer: B Explanation: process.env holds all environment variables; NODE_ENV is a common one for mode. Question 33. Which signal is sent to a Node process when the user presses Ctrl+C? A) SIGTERM B) SIGINT C) SIGHUP D) SIGKILL Answer: B Explanation: Ctrl+C triggers the SIGINT interrupt signal. Question 34. The os.cpus() method returns: A) The number of CPU cores as a number. B) An array of objects describing each logical CPU. C) The current CPU usage percentage. D) The CPU architecture string. Answer: B Explanation: It provides detailed info for each logical CPU core.
B) express.json() C) bodyParser.text() D) express.static() Answer: B Explanation: express.json() adds a parser for application/json payloads. Question 39. Which HTTP method is idempotent? A) POST B) GET C) PATCH D) CONNECT Answer: B Explanation: GET can be repeated without side effects; POST is not idempotent. Question 40. To protect an Express app from HTTP Parameter Pollution, you should: A) Use helmet.hidePoweredBy(). B) Validate and whitelist allowed query parameters. C) Enable CORS for all origins. D) Set app.set('trust proxy', true). Answer: B Explanation: Whitelisting prevents duplicate or unexpected parameters that could cause pollution. Question 41. Which of the following is a common mitigation against Denial‑of‑Service (DoS) attacks in a Node server? A) Disabling TLS. B) Limiting request body size with express.json({ limit: '1mb' }).
C) Enabling node --trace-warnings. D) Using eval for request handling. Answer: B Explanation: Restricting payload size helps prevent resource exhaustion. Question 42. In Fastify, the schema property is used to: A) Define routing prefixes. B) Validate request/response payloads. C) Set up database connections. D) Enable compression. Answer: B Explanation: Fastify’s built‑in schema validation ensures data conforms to defined structures. Question 43. Which Node.js core module provides utilities for debugging and formatting strings? A) util B debug C) assert D) console Answer: A Explanation: The util module includes util.debuglog, util.format, and more. Question 44. Which of the following correctly creates a class with a private field #id? A) class User { #id; constructor(id){ this.#id = id; } } B) class User { private id; constructor(id){ this.id = id; } } C) function User(id){ this.#id = id; }
B) Arrow functions have their own this context. C) Arrow functions inherit this from the surrounding scope. D) Arrow functions cannot access this at all. Answer: C Explanation: Arrow functions do not create their own this; they use the surrounding lexical this. Question 48. Which of the following is not a valid Buffer encoding? A) utf8 B) ascii C) hex D) binary64 Answer: D Explanation: binary64 is not a recognized Buffer encoding; common ones include utf8, ascii, hex, base64. Question 49. In a Transform stream, which method must be implemented to process incoming chunks? A) _read B) _write C) _transform D) _flush Answer: C Explanation: _transform receives each chunk, processes it, and pushes the transformed data. Question 50. Which of the following correctly creates a Readable stream from an array of strings?
A) stream.Readable.from(['a','b']) B) new stream.Readable(['a','b']) C) fs.createReadStream(['a','b']) D) stream.array(['a','b']) Answer: A Explanation: Readable.from creates a stream from any iterable. Question 51. What does the process.nextTick function do? A) Schedules a callback after the current poll phase. B) Executes the callback immediately, before any I/O. C) Defers execution to the next event‑loop tick, after the current operation completes. D) Runs the callback in a separate OS thread. Answer: C Explanation: process.nextTick queues a microtask that runs after the current call stack but before the next event‑loop phase. Question 52. Which of the following methods can synchronously read a directory’s contents? A) fs.readdir B) fs.readdirSync C) fs.promises.readdir D) fs.watch Answer: B Explanation: The Sync variant performs a blocking read of directory entries. Question 53. In Node, the cluster module is primarily used for: A) Managing child processes that run separate scripts.
Question 56. Which fs method can be used to atomically replace the contents of a file? A) fs.writeFile B) fs.rename after writing to a temporary file C) fs.truncate D) fs.appendFile Answer: B Explanation: Writing to a temp file and then renaming ensures atomic replacement on most filesystems. Question 57. Which of the following is the correct way to import a CommonJS module in an ES module? A) import pkg from './pkg.cjs'; B) import * as pkg from './pkg.cjs'; C) const pkg = require('./pkg.cjs'); (only in CommonJS) D) Both A and B (depending on package.json type) Answer: D Explanation: When the file is flagged as ES module, import works; otherwise, require is needed. Question 58. What does the --harmony flag do when starting Node? A) Enables all staged ECMAScript features. B) Turns on experimental V8 garbage collection. C) Disables strict mode. D) Starts Node in interactive REPL mode. Answer: A Explanation: --harmony enables a set of experimental ECMAScript features.
Question 59. Which of the following is not a valid way to set a timeout for a promise? A) Promise.race([p, new Promise((_,reject)=>setTimeout(()=>reject(new Error('timeout')),1000))]) B) p.timeout(1000) (assuming no library) C) Using AbortController with fetch. D) Wrapping the promise in util.promisify(setTimeout) and chaining. Answer: B Explanation: Native promises have no .timeout method; you must implement a race or use external libraries. Question 60. In the context of Node streams, what does backpressure refer to? A) The ability of a readable stream to push data faster than a writable can consume. B) The writable stream’s internal buffer filling up, causing the readable to pause. C) A memory leak caused by unhandled errors. D) The use of setImmediate to schedule callbacks. Answer: B Explanation: Backpressure occurs when the writable cannot keep up, signalling the readable to slow down. Question 61. Which method of the EventEmitter class returns the number of listeners for a specific event? A) listenerCount(eventName) B) listeners(eventName).length C) eventNames() D) Both A and B (A is static) Answer: D