nodejs-output_edited
nodejs-output_edited
QUESTION 1
What is Node.js primarily used for?
A. Frontend Development
B. Backend Development
C. Database Management
D. Game Development
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 2
Which language does Node.js use?
A. Python
B. Java
C. JavaScript
D. Ruby
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 3
Node.js is based on which runtime environment?
A. V8
B. Chakra
C. SpiderMonkey
D. Rhino
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 4
How does Node.js handle I/O operations?
A. Synchronous
B. Asynchronous
C. Concurrent
D. Serial
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 5
Which keyword is used to import modules in Node.js?
A. import
B. include
C. require
D. fetch
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 6
What does module.exports do?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 7
Which module is used for creating an HTTP server?
A. http
B. server
C. os
D. express
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 8
What does NPM stand for?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 9
How do you install a package globally using NPM?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 10
What file contains dependencies for a Node.js project?
A. config.json
B. npm.json
C. package.json
D. dependencies.json
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 11
Which function executes code after a specified delay?
A. setTimeout
B. setInterval
C. setDelay
D. asyncFunction
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 12
Which Node.js module provides utilities for working with asynchronous callbacks?
A. fs
B. async
C. util
D. callbacks
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 13
Node.js relies on which architecture to handle events?
A. Procedural
B. Synchronous
C. Event-driven
D. Multi-threaded
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 14
Which module is central to event handling in Node.js?
A. fs
B. events
C. http
D. emitter
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 15
What is Express.js primarily used for in Node.js?
A. Frontend styling
B. Data modeling
C. Server-side framework
D. Testing
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 16
What function is used to create a route in Express.js?
A. expressRoute()
B. route()
C. app.route()
D. app.get()
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 17
Which of the following is a best practice in Node.js?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 18
What type of logging is recommended for production?
A. console.log
B. Verbose logging
C. Structured logging
D. Debug logging
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 19
Which protocol does WebSocket use?
A. HTTP
B. HTTPS
C. ws://
D. socket.io
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 20
What is the primary purpose of WebSocket?
A. Database connections
B. Real-time, two-way communication
C. File transfer
D. Video streaming
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 21
In Express.js, middleware functions can modify the:
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 22
What is the typical position of middleware in Express routes?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 23
Which method is used to read data in chunks in Node.js?
A. read()
B. pipe()
C. chunk()
D. stream()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 24
Which type of stream is used to read data?
A. Writable
B. Readable
C. Duplex
D. Transform
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 25
Which function is used to read a file synchronously in Node.js?
A. fs.read()
B. fs.readSync()
C. fs.readFileSync()
D. fs.syncRead()
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 26
How do you write data to a file in an asynchronous way?
A. fs.writeFileSync
B. fs.appendFile
C. fs.writeFile
D. fs.writeAsync
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 27
What does a Promise represent?
A. A synchronous function
B. A completed task
C. An eventual result of an asynchronous operation
D. A user input
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 28
What does the await keyword do in an async function?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 29
What is the purpose of the Event Loop in Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 30
The Event Loop executes which type of operations first?
A. Network I/O
B. Timers
C. Microtasks
D. File operations
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 31
Which of the following is a Node.js feature?
A. Blocking I/O
B. Single-threaded event loop
C. Multi-threaded architecture
D. Client-side scripting
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 32
What kind of applications is Node.js well-suited for?
A. CPU-intensive applications
B. I/O-bound applications
C. GUI-based applications
D. Desktop applications
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 33
Which built-in method is used to output logs to the console in Node.js?
A. log()
B. console()
C. output()
D. console.log()
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Modules and Require (Extended)
QUESTION 34
Which of the following is NOT a core module in Node.js?
A. os
B. http
C. express
D. path
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 35
How would you import a custom module located in the same directory?
A. require('./module')
B. require('module')
C. import('module')
D. module.exports('./module')
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 36
How do you export multiple functions from a Node.js module?
Correct Answer: AB
Section: (none)
Explanation
Explanation/Reference:
QUESTION 37
Which command lists globally installed npm packages?
A. npm list
B. npm list -g
C. npm -global list
D. npm show global
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 38
What does the --save flag do when installing an npm package?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 39
How do you update npm itself to the latest version?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 40
What does the callback function in asynchronous functions prevent?
A. Race conditions
B. Deadlocks
C. Blocking code execution
D. High memory usage
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 41
Which of the following can handle asynchronous operations in Node.js?
A. Events
B. Promises
C. async/await
D. All of the above
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 42
What is a callback hell?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 43
How do you listen to events in Node.js?
A. By calling event.on()
B. By calling event.listen()
C. By using event.subscribe()
D. By creating a new EventListener()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 44
Which method is used to emit an event in Node.js?
A. emit()
B. on()
C. trigger()
D. call()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 45
What is a key advantage of an event-driven model in Node.js?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 46
What is the default port used by Express applications?
A. 80
B. 443
C. 3000
D. 5000
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 47
Which middleware is commonly used for parsing JSON in Express?
A. body-parser
B. json-parser
C. cookie-parser
D. express-parser
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 48
How do you handle errors globally in Express?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 49
What is a recommended way to structure a Node.js project?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 50
What should you avoid when working with sensitive data in Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 51
Why is it recommended to use async/await in Node.js applications?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 52
Which library is commonly used for WebSocket communication in Node.js?
A. http
B. ws
C. socket.io
D. net
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 53
What method initiates a WebSocket connection?
A. ws.start()
B. ws.connect()
C. new WebSocket()
D. ws.open()
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 54
What does WebSocket enable for real-time applications?
A. File upload
B. Bi-directional communication
C. Asynchronous file read
D. HTTP-based communication
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 55
What is the role of next() in Express middleware?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 56
In which order does Express execute middleware functions?
A. Alphabetical order
B. Reverse order of declaration
C. Order of declaration
D. Random order
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 57
How can you pipe data from a readable stream to a writable stream in Node.js?
A. readable.pipe(writable)
B. writable.pipe(readable)
C. readable.write(writable)
D. writable.read(readable)
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 58
Which event is emitted when a readable stream ends?
A. close
B. end
C. finish
D. stop
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 59
Which method is used to check if a file exists in Node.js?
A. fs.existsSync()
B. fs.fileExists()
C. fs.check()
D. fs.accessSync()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 60
Which fs method is used to delete a file asynchronously?
A. fs.delete()
B. fs.remove()
C. fs.unlink()
D. fs.rm()
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 61
What does the then() method of a Promise do?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 62
How do you handle errors in a Promise chain?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 63
What kind of tasks does the Event Loop prioritize in Node.js?
A. Network requests
B. Timers
C. Microtasks
D. File I/O
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 64
What are the phases of the Event Loop?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 65
Which of the following describes Node.js's single-threaded model?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 66
Which of the following is true about Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 67
Which built-in Node.js module allows you to work with the operating system?
A. fs
B. os
C. http
D. path
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 68
Which module allows you to parse JSON files in Node.js?
A. json-parser
B. json
C. fs
D. path
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 69
How do you access the version of a Node.js module from within your code?
A. module.version
B. require('module').version
C. module.info()
D. node.getVersion()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 70
How can you use a Node.js module without installing it?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 71
Which command is used to initialize a new Node.js project and generate a package.json file?
A. npm create
B. npm init
C. npm start
D. npm install
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 72
How would you uninstall a package globally using NPM?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 73
Which command can you use to check for outdated npm packages?
A. npm outdated
B. npm check
C. npm list --outdated
D. npm update --outdated
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 74
Which function is used to schedule a one-time delay for executing code in Node.js?
A. setTimeout()
B. setInterval()
C. setDelay()
D. asyncWait()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 75
What happens if a callback function is not passed to an asynchronous function?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 76
Which method in Node.js can handle multiple asynchronous operations concurrently?
A. async.series()
B. async.parallel()
C. Promise.all()
D. async.all()
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 77
How do you define an event emitter in Node.js?
A. new EventEmitter()
B. events.createEmitter()
C. Emitter.create()
D. new EventListener()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 78
What will happen if an event is emitted but no listeners are attached in Node.js?
A. Nothing happens
B. The event will be lost
C. Node.js throws an error
D. Node.js will create a default listener
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 79
How do you remove a listener from an event emitter?
A. emitter.removeListener(event, listener)
B. emitter.off(event, listener)
C. emitter.remove(event)
D. emitter.remove(listener)
Correct Answer: AB
Section: (none)
Explanation
Explanation/Reference:
QUESTION 80
Which method is used to serve static files in Express.js?
A. app.use(express.static())
B. express.serveStatic()
C. app.serveStatic()
D. express.static()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 81
Which HTTP method does Express.js use to handle POST requests?
A. app.get()
B. app.post()
C. app.put()
D. app.delete()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 82
Which of the following is correct for handling errors in Express?
A. app.error()
B. app.handleError()
C. app.use() with a four-argument function
D. express.use()
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 83
What should be the main concern when handling errors in Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 84
Which tool is commonly used for testing Node.js applications?
A. Jest
B. Mocha
C. Jasmine
D. All of the above
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 85
Why is using environment variables for configuration considered a best practice?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 86
How do WebSockets maintain an open connection?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 87
Which of the following best describes WebSocket's advantages?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 88
Which WebSocket event is fired when the connection is closed?
A. close
B. end
C. terminate
D. disconnect
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 89
What is the purpose of body parsers in Express.js middleware?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 90
Which method in Express allows for chaining multiple middleware?
A. app.all()
B. app.use()
C. app.route()
D. app.middleware()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 91
Which HTTP method is used to mount middleware that applies to a specific route?
A. app.use()
B. app.get()
C. app.post()
D. app.all()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 92
What is the difference between a readable and a writable stream in Node.js?
A. Readable streams emit data that can be consumed, while writable streams accept data to write
B. Readable streams store data, while writable streams send data
C. Readable streams are for network operations, writable streams are for file I/O
D. Writable streams process data asynchronously, readable streams process it synchronously
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 93
Which stream method is used to pipe the output of one stream into another?
A. pipe()
B. link()
C. merge()
D. flow()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 94
Which method allows asynchronous reading of a file in Node.js?
A. fs.readFileSync()
B. fs.readFile()
C. fs.read()
D. fs.asyncRead()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 95
Which of the following will create a new directory asynchronously?
A. fs.mkdirSync()
B. fs.createDirectory()
C. fs.mkdir()
D. fs.create()
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 96
Which of the following does the async keyword indicate in front of a function?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 97
What does Promise.all() return when one of the promises fails?
A. Promise.reject()
B. Promise.all() ignores the failure
C. Promise.all() waits for all promises
D. Promise.all() rejects with the error of the first failed promise
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 98
At which phase does the Event Loop process I/O events?
A. Poll phase
B. Timer phase
C. Check phase
D. Immediate phase
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 99
What is the main role of the Event Loop in Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 100
Which phase comes after the poll phase in the Node.js Event Loop?
A. Check phase
B. Immediate phase
C. Timer phase
D. Idle phase
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 101
Which of the following can be considered an advantage of using Node.js for server-side development?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 102
What does the process.exit() method do in a Node.js application?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 103
Which of the following is used to handle child processes in Node.js?
A. Os
B. http
C. child_process
D. fs
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 104
What does the module.exports object in Node.js do?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 105
Which of the following is NOT a feature of Node.js modules?
A. Encapsulation of code
B. Code reusability
C. Blocking I/O
D. Support for synchronous code execution
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 106
Which of the following will import a file located in a different directory?
A. require('./myModule')
B. require('../myModule')
C. require('/myModule')
D. import myModule
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 107
Which command installs all dependencies listed in package.json?
A. npm install
B. npm update
C. npm upgrade
D. npm start
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 108
Which file is created when you initialize a Node.js project using npm init?
A. index.js
B. node_modules.json
C. package.json
D. dependencies.json
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 109
How can you uninstall a package without removing its dependencies?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 110
Which of the following is a correct way to use async/await in Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 111
How do you execute multiple promises in parallel using Promise.all()?
A. Promise.all([promise1, promise2])
B. Promise.all(promise1, promise2)
C. Promise.all(promise1 && promise2)
D. Promise.parallel([promise1, promise2])
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 112
Which is the best way to handle errors in async functions?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 113
In Node.js, what type of pattern is commonly used for managing events?
A. Publisher-Subscriber pattern
B. Observer pattern
C. Event Queue pattern
D. Request-Response pattern
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 114
What is emitted when an error occurs in Node.js Event Emitters?
A. error event
B. exception event
C. errorOccurred event
D. failure event
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 115
Which method allows you to remove all listeners for a specific event in Node.js?
A. emitter.removeAllListeners()
B. emitter.removeListeners()
C. emitter.clearListeners()
D. emitter.deleteListeners()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 116
What does app.listen() do in an Express.js application?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 117
How would you define a route for handling GET requests at the /home path in Express?
Correct Answer: AB
Section: (none)
Explanation
Explanation/Reference:
QUESTION 118
Which middleware is used to handle cookie parsing in Express?
A. cookie-parser
B. cookie-handler
C. cookie-manager
D. express-cookie
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 119
What is the purpose of using a .env file in Node.js projects?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 120
Which of the following is a best practice when dealing with untrusted data in Node.js applications?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 121
Which logging library is often used in Node.js applications for structured logging?
A. Winston
B. log4js
C. morgan
D. All of the above
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 122
Which event is triggered when a WebSocket connection is established?
A. Open
B. Connect
C. Start
D. Ready
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 123
How do you send data from a WebSocket server to the client?
A. ws.send(data)
B. ws.emit(data)
C. ws.push(data)
D. ws.broadcast(data)
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 124
What is the purpose of WebSocket's ping and pong messages?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 125
What does the next() function do in middleware for handling requests in Express.js?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 126
Which type of middleware is executed before route handling middleware in Express?
A. Application-level middleware
B. Route-level middleware
C. Error-handling middleware
D. Built-in middleware
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 127
How can you limit the number of requests made by the client in a certain period?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 128
Which method is used to read data from a readable stream?
A. stream.read()
B. stream.pipe()
C. stream.output()
D. stream.get()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 129
What is the advantage of using streams over loading a file entirely into memory?
A. Streams allow reading and writing data as it is being processed, reducing memory usage
B. Streams store data in memory and thus are faster
C. Streams process files more slowly
D. Streams require less CPU usage
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 130
How can you pause a readable stream?
A. stream.pause()
B. stream.stop()
C. stream.close()
D. stream.suspend()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 131
Which of the following is the primary reason Node.js is preferred for I/O-heavy applications?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 132
Which of the following is true about Node.js?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 133
Which built-in Node.js module helps you work with paths and file system operations?
A. http
B. path
C. events
D. fs
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 134
How would you require a JSON file in Node.js?
A. require('./data.json')
B. import('./data.json')
C. require('./data.json') (but only if it contains JavaScript code)
D. require('./data')
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 135
Which command can you use to create a custom module in Node.js?
A. node module.create
B. require('./myModule')
C. module.exports
D. Custom modules are not allowed in Node.js
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 136
What is the purpose of exports in Node.js?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 137
Which command installs a package globally?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 138
How can you search for a package using NPM?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 139
What is package-lock.json used for?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 140
What happens when you call an asynchronous function without a callback in Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 141
What is the main difference between callbacks and promises in Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 142
Which of the following would you use to handle multiple asynchronous tasks and wait for them all to
complete?
A. Promise.any()
B. Promise.all()
C. async.parallel()
D. Promise.resolve()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 143
What is the default maximum number of listeners for each event in Node.js's EventEmitter?
A. 10
B. 100
C. 50
D. 1
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 144
Which of the following is true about events in Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 145
How do you emit a custom event in Node.js?
A. emitter.emit('eventName')
B. emitter.raise('eventName')
C. emitter.dispatch('eventName')
D. emitter.trigger('eventName')
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 146
What does the express.Router() method do?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 147
Which of the following is true about using middleware in Express.js?
Explanation/Reference:
QUESTION 148
Which HTTP method should you use to handle form submissions in Express?
A. app.get(
B. app.delete()
C. app.post()
D. app.head()
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 149
Which of the following should you consider when writing scalable applications in Node.js?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 150
Which of the following is a good practice when deploying a Node.js application in production?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 151
What is one of the most common ways to monitor a Node.js application in production?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 152
What type of protocol does WebSocket use for communication?
A. HTTP
B. HTTPS
C. TCP
D. UDP
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 153
What happens if you try to send a message over a closed WebSocket connection?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 154
Which of the following is a key feature of WebSocket?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 155
How can you create a custom error-handling middleware in Express.js?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 156
Which middleware in Express helps in parsing incoming JSON data?
A. express.json()
B. express.bodyParser()
C. express.parseJSON()
D. express.body()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 157
How would you prevent a specific route in Express from being accessed by unauthorized users?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 158
Which of the following methods can be used to pipe a readable stream to a writable stream?
A. stream.pipe(destination)
B. stream.writeTo(destination)
C. stream.transfer(destination)
D. stream.send(destination)
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 159
What type of stream is used for reading data from a file in Node.js?
A. Readable stream
B. Writable stream
C. Duplex stream
D. Transform stream
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 160
What method would you use to end a writable stream after writing data?
A. stream.close()
B. stream.end()
C. stream.stop()
D. stream.closeWrite()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 161
Which Node.js function is used to get the current working directory?
A. process.cwd()
B. os.cwd()
C. path.cwd()
D. process.getcwd()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 162
What is the primary role of Node.js in the MEAN stack?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 163
Which of the following is NOT a common use case for Node.js?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 164
How would you load a local module in Node.js?
A. require('moduleName')
B. require('./moduleName')
C. import('./moduleName')
D. module.import('./moduleName')
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 165
Which of the following is the correct way to export a single function from a module in Node.js?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 166
Which Node.js module can be used to interact with the operating system and retrieve system
information?
A. Path
B. Os
C. http
D. fs
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 167
How would you view the details of a specific package installed via NPM?
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 168
Which of the following NPM commands creates a package-lock.json file?
A. npm install
B. npm init
C. npm update
D. npm config set
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 169
What command is used to install a package as a development dependency in NPM?
Explanation/Reference:
QUESTION 170
Which function is used to handle the result of an asynchronous operation in a promise chain?
A. .catch()
B. .then()
C. .finally()
D. .complete()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 171
What does the async keyword do in an asynchronous function?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 172
What happens if you throw an error inside an async function?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 173
Which of the following is true about event-driven architecture in Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 174
How can you modify the maximum number of listeners for an event in Node.js?
A. emitter.setMaxListeners(20)
B. emitter.maxListeners(20)
C. emitter.changeMaxListeners(20)
D. emitter.setListeners(20)
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 175
Which method would you use to listen for custom events in Node.js?
A. emitter.on('eventName', callback)
B. emitter.addListener('eventName', callback)
C. Both a and b
D. emitter.listen('eventName', callback)
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 176
Which middleware function is commonly used to log HTTP requests in Express.js?
A. Morgan
B. body-parser
C. cookie-parser
D. express-log
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 177
How would you add a route that listens for PUT requests at the /update path in Express?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 178
Which of the following is the correct way to handle static files in Express?
A. app.use(express.static('public'))
B. app.static('public')
C. app.useStatic('public')
D. app.staticFiles('public')
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 179
Which of the following is a best practice for handling errors in Node.js applications?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 180
Which of the following is the best approach for managing a large Node.js application?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 181
What should you do to handle uncaught exceptions in a Node.js application?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
WebSocket Communication (Extended)
QUESTION 182
Which WebSocket method would you use to send a message from the server to the client?
A. ws.send()
B. ws.emit()
C. ws.sendMessage()
D. ws.push(
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 183
Which of the following is the correct way to close a WebSocket connection from the server?
A. ws.close()
B. ws.disconnect()
C. ws.terminate()
D. ws.end()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 184
How do you handle WebSocket message events in the client?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 185
How would you add a middleware that runs only for specific HTTP methods in Express?
A. app.use(method, middleware)
B. app.use('/path', method, middleware)
C. app[method]('/path', middleware)
D. app.method('/path', middleware)
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 186
Which of the following is used to serve static files in Express?
A. app.use(express.static(path))
B. app.serve(path)
C. app.staticFiles(path)
D. app.serveStatic(path)
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 187
How would you add a middleware for handling JSON payloads in Express.js?
A. app.use(express.json())
B. app.json(express())
C. app.bodyParser()
D. app.use(express.payload())
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 188
Which of the following streams can be used to transform data before passing it to the next stream?
A. Readable stream
B. Writable stream
C. Transform stream
D. Duplex stream
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 189
Which method is used to pause a writable stream?
A. stream.pause()
B. stream.stop()
C. stream.end()
D. stream.suspend()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 190
What is the purpose of the stream.finished() method in Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 191
What is the output of console.log(process.argv) in a Node.js program?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 192
Which of the following would be the best way to ensure your Node.js application handles a large
number of concurrent users?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 193
Which command would you use to check the version of Node.js installed on your system?
A. node –version
B. node –v
C. node version
D. Both a and b
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 194
What does require() do in Node.js?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 195
How do you export an object from a Node.js module?
A. module.export = object
B. exports = object
C. module.exports = object
D. object.export()
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 196
Which of the following will correctly import the fs module in Node.js?
Correct Answer: AB
Section: (none)
Explanation
Explanation/Reference:
QUESTION 197
What does the command npm uninstall <package> do?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 198
What does the npm outdated command do?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 199
What is the purpose of the npm update command?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 200
Which of the following is a method used to handle multiple promises concurrently and return a single
promise?
A. Promise.all()
B. Promise.race()
C. Promise.finally()
D. Promise.any()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 201
What does await do in JavaScript?
A. It pauses the execution of the async function until the promise is resolved or rejected
B. It starts a promise-based function
C. It handles promise rejections
D. It waits for a setTimeout to finish
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 202
Which function is used to handle promise rejections in Node.js?
A. .catch()
B. .then()
C. .finally()
D. .reject()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 203
What is an event loop in Node.js?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 204
How can you remove all listeners for a specific event from an EventEmitter instance?
A. emitter.removeListener('eventName')
B. emitter.removeAllListeners('eventName')
C. emitter.off('eventName')
D. emitter.clearListeners('eventName')
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 205
What is the purpose of the once() method in Node.js EventEmitter?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 206
Which method is used to send an HTTP response with a specific HTTP status code in Express?
A. res.statusCode(404)
B. res.sendStatus(404)
C. res.send(404)
D. res.status(404).send('Not Found')
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 207
Which of the following is used to parse incoming requests with JSON payloads in Express?
A. app.use(express.json())
B. app.use(bodyParser.json())
C. app.use(express.bodyParser())
D. app.bodyParser()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 208
How can you chain route handlers in Express.js?
A. Using app.route()
B. Using app.all()
C. Using app.handle()
D. Using app.middleware()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 209
Which of the following is a common practice for optimizing performance in Node.js?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 210
When should you use environment variables in a Node.js application?
A. To store sensitive configuration data like API keys and database credentials
B. To store application logic
C. To store client-side data for use in templates
D. Only to store temporary data
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 211
What is the recommended way to handle long-running operations in a Node.js application?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 212
Which event is triggered when the WebSocket connection is closed?
A. ws.disconnect
B. ws.close
C. ws.end
D. ws.onclose
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 213
How can you broadcast a message to all connected WebSocket clients from the server?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 214
Which protocol is WebSocket built upon?
A. HTTP
B. HTTPS
C. TCP
D. UDP
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 215
Which of the following is the purpose of express.static() middleware?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 216
How would you use middleware to handle errors in Express.js?
A. app.use(errorHandler)
B. app.all('/error', errorHandler)
C. app.error(errorHandler)
D. app.use('/error', errorHandler)
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 217
What is the purpose of the next parameter in Express middleware?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 218
Which of the following is used to run a Node.js application?
A. node <filename>
B. node run <filename>
C. node execute <filename>
D. node start <filename>
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 219
What is the default port number for a Node.js server?
A. 3000
B. 8080
C. 80
D. 5000
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 220
Which method is used to listen for incoming requests on a specific port in Node.js?
A. server.listen(port)
B. server.start(port)
C. server.open(port)
D. server.bind(port)
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 221
What happens if a module is required multiple times in Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 222
Which of the following is true about CommonJS modules in Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 223
How would you export multiple functions or variables from a Node.js module?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 224
How would you install a package globally using npm?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 225
What does the npm audit command do?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 226
What command is used to create a package.json file for a Node.js project?
A. npm create
B. npm init
C. npm setup
D. npm package
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 227
Which of the following is true about setTimeout() in Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 228
What does Promise.all() return when all promises are resolved successfully?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 229
What does the finally() method do in a promise chain?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 230
Which of the following is the best description of an event-driven architecture in Node.js?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 231
How can you emit a custom event in Node.js using an EventEmitter?
A. emitter.emit('eventName', data)
B. emitter.trigger('eventName', data)
C. emitter.raise('eventName', data)
D. emitter.dispatch('eventName', data)
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 232
What is the purpose of the process.on('uncaughtException', callback) method?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 233
Which of the following is used to handle 404 errors in Express.js?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 234
What is the purpose of the app.all() method in Express?
A. It is used to define a handler for all HTTP methods (GET, POST, etc.) for a given path
B. It is used to serve all types of files from a specific directory
C. It defines all routes globally for the app
D. It is used to listen for incoming requests on all ports
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 235
How would you use Express to parse a URL-encoded body (as submitted by a form)?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 236
Which of the following best practices should be followed when deploying a Node.js application in
production?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 237
What is the recommended method for error handling in an asynchronous function in Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 238
What is the advantage of using worker threads in Node.js?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 239
Which of the following would you use to send a message to all clients connected to the WebSocket
server?
A. ws.broadcast('message')
B. ws.sendToAll('message')
C. You would need to manually iterate over each connected WebSocket instance and send the
message
D. ws.emit('message')
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 240
Which event is fired when a message is received from the client in a WebSocket connection?
A. Message
B. Data
C. Receive
D. onmessage
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 241
How do you handle a WebSocket error in the client?
A. socket.on('error', callback)
B. socket.error(callback)
C. socket.onerror(callback)
D. socket.catch(callback)
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 242
Which of the following middleware functions is used to parse cookies in an Express.js app?
A. cookieParser()
B. express.cookie()
C. cookieParserMiddleware()
D. app.cookies()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 243
What is the default status code returned by Express when no status code is specified?
A. 200 (OK)
B. 404 (Not Found)
C. 500 (Internal Server Error)
D. 301 (Moved Permanently)
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 244
Which of the following is used to prevent Cross-Origin Resource Sharing (CORS) issues in Express.js?
A. express-cors
B. cors middleware
C. app.enableCORS()
D. app.allowCrossOrigin()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 245
Which of the following is a core module of Node.js?
A. Fs
B. Path
C. http
D. All of the above
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 246
Which command is used to run a Node.js file directly from the terminal?
Explanation/Reference:
QUESTION 247
In Node.js, which method can you use to read a file asynchronously?
A. fs.readFileSync()
B. fs.readFile()
C. fs.read()
D. fs.loadFile()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 248
How would you require a built-in Node.js module in your project?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 249
Which method would you use to dynamically load a module in Node.js?
A. require()
B. import()
C. load()
D. module.import()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 250
What does module.exports do in a Node.js module?
A. Exports the module’s public API
B. Import the module’s public API
C. Imports functions from other modules
D. Defines the entire module inside a file
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 251
What does the command npm run <script> do?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 252
What does the npm install command do when run in an existing project?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 253
What is the purpose of the npm start command in a Node.js project?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 254
What does the setImmediate() function do in Node.js?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 255
What is the result of calling Promise.reject('error')?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 256
What is a key difference between setTimeout() and setImmediate()?
A. setTimeout() executes a callback after the specified delay, while setImmediate() runs the callback
on the next iteration of the event loop
B. setTimeout() always runs synchronously, while setImmediate() is asynchronous
C. setTimeout() is used to handle errors, while setImmediate() handles regular tasks
D. setTimeout() executes in the next event loop, while setImmediate() waits until the script is finished
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 257
Which of the following is true about the EventEmitter class in Node.js?
Explanation/Reference:
QUESTION 258
Which of the following is the correct syntax to add an event listener to an EventEmitter instance?
A. emitter.addListener('event', callback)
B. emitter.on('event', callback)
C. emitter.subscribe('event', callback)
D. emitter.event(callback)
Correct Answer: AB
Section: (none)
Explanation
Explanation/Reference:
QUESTION 259
What does the process.nextTick() function do in Node.js?
A. Executes a callback after the current operation completes, before the event loop continues
B. Executes a callback after the current event loop iteration
C. Schedules a task to be performed immediately
D. Immediately terminates the process and logs errors
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 260
Which of the following is the correct way to define a GET route in Express?
Correct Answer: AB
Section: (none)
Explanation
Explanation/Reference:
QUESTION 261
Which middleware function would you use to parse incoming form data in Express?
A. express.bodyParser()
B. express.json()
C. express.urlencoded()
D. bodyParser()
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 262
What is the primary purpose of the next() function in Express middleware?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 263
Which of the following is a best practice for handling errors in Node.js applications?
A. Always log errors to the console and allow the application to continue running
B. Return detailed error messages to the client to help debug
C. Use try/catch blocks and reject unhandled promise rejections
D. Let errors go unhandled to improve performance
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 264
What is the best way to scale a Node.js application?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 265
What is the purpose of using dotenv in a Node.js application?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 266
Which of the following is true about WebSocket communication in Node.js?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 267
How would you close a WebSocket connection from the server side?
A. ws.close()
B. ws.disconnect()
C. ws.terminate()
D. ws.end()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 268
How can you handle errors when using WebSocket in a Node.js client?
Explanation/Reference:
QUESTION 269
Which of the following middleware functions would you use to serve static files in an Express.js
application?
A. app.static()
B. express.static()
C. app.serveStatic()
D. serve.static()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 270
What is the primary function of middleware in an Express.js application?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 271
Which middleware function is used to parse incoming JSON payloads in Express?
A. express.json()
B. express.bodyParser()
C. express.parseJson()
D. jsonParser()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 272
What does process.env in Node.js represent?
A. The current file directory
B. An object containing environment variables
C. The version of Node.js
D. A list of installed modules
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 273
How does Node.js handle multiple requests?
A. Using multithreading
B. Using a single-threaded, non-blocking I/O model
C. By creating multiple instances of the app
D. Using synchronous functions only
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 274
What is the purpose of exports in Node.js?
A. To import modules
B. To export objects and functions from a module
C. To read external files
D. To handle events
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 275
How do you make only specific functions or variables accessible from a Node.js module?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 276
Which of the following statements is false regarding module.exports and exports?
A. Both module.exports and exports are references to the same object initially
B. You can reassign exports directly to export an object
C. exports is a shorthand for module.exports
D. Using module.exports allows exporting a single function or object
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 277
What file is used by npm to determine the dependencies of a project?
A. package.json
B. npm-config.json
C. dependencies.json
D. module.json
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 278
What command updates all packages to their latest versions in an npm project?
A. npm update
B. npm upgrade
C. npm latest
D. npm all-update
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 279
What does the ^ symbol in package.json version numbers represent?
Explanation/Reference:
Asynchronous Programming (Extended)
QUESTION 280
Which of the following functions does not return a promise?
A. setTimeout()
B. fetch()
C. fs.promises.readFile()
D. Promise.resolve()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 281
How do you convert a callback-based function into a promise-based function in Node.js?
A. Using async/await
B. Using Promise.wrap()
C. Using Promise.promisify()
D. Using Promise.create()
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 282
What will Promise.race([p1, p2, p3]) return if p2 resolves first?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 283
Which method is used to remove a specific listener from an event in EventEmitter?
A. emitter.removeListener(event, listener)
B. emitter.off(event, listener)
C. emitter.removeEvent(event)
D. emitter(event, listener)
Correct Answer: AB
Section: (none)
Explanation
Explanation/Reference:
QUESTION 284
What event is emitted when an error occurs in Node.js?
A. Error
B. Exception
C. Crash
D. uncaughtException
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 285
How can you prevent an application from crashing when an unhandled error occurs in an
EventEmitter?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Express.js Framework (Extended)
QUESTION 286
How would you configure Express to serve static files from a directory?
A. app.use(express.static('public'))
B. app.static('public')
C. app.serve('public')
D. app.serveStatic('public')
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 287
What is the role of the app.listen() function in an Express application?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 288
Which of the following methods defines middleware for handling JSON payloads in Express?
A. app.use(express.json())
B. app.use(express.bodyParser())
C. app.json()
D. app.bodyParser()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 289
What is the recommended way to secure environment variables in a Node.js project?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 290
What is a common way to improve application performance in Node.js?
Explanation/Reference:
QUESTION 291
Which tool is commonly used for logging in production-grade Node.js applications?
A. console.log()
B. fs.appendFile()
C. Winston
D. logger.debug()
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 292
Which protocol upgrade does WebSocket use to establish a connection over HTTP?
A. HTTP/2
B. WebSocket handshake
C. TCP/IP upgrade
D. HTTP upgrade
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 293
Which event listener would you use to detect when a WebSocket connection is closed?
A. socket.on('disconnect')
B. socket.on('close')
C. socket.on('end')
D. socket.on('exit')
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 294
What is the purpose of ws.send() in a WebSocket server?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 295
In Express, which method is typically used to handle errors across the application?
A. app.error()
B. app.use((err, req, res, next) => { ... })
C. app.catch((err) => { ... })
D. app.handleError((err) => { ... })
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 296
What is the order of middleware execution in Express.js?
A. Alphabetical order
B. In the order they are defined in the code
C. Based on middleware priority level
D. Random order
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 297
Which type of middleware can modify the request object in Express.js before it reaches the route
handler?
A. Error-handling middleware
B. Application-level middleware
C. Request-modifying middleware
D. Route handler middleware
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 298
Which of the following is an example of a readable stream in Node.js?
A. fs.createReadStream()
B. fs.writeFile()
C. fs.appendFile()
D. http.get()
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 299
Which event is emitted by writable streams when they are ready to accept more data?
A. Data
B. Drain
C. Ready
D. open
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 300
What is the purpose of a for...of loop in JavaScript?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 301
What is the output of the following code? javascript const arr = [1, 2, 3]; for (let i = 0; i < arr.length; i++)
{ if (i === 1) break; console.log(arr[i]); }
A. 1, 2, 3
B. 2
C. 1
D. 1, 2
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 302
Which loop would you use when the number of iterations is unknown but depends on a condition?
A. for loop
B. while loop
C. do...while loop
D. none of the above
Correct Answer: AB
Section: (none)
Explanation
Explanation/Reference:
QUESTION 303
What is the main difference between for...in and for...of loops?
A. for...in loops through array elements, and for...of loops through object properties
B. for...in loops through object properties, and for...of loops through iterable elements
C. Both loops function identically
D. for...in is used only for arrays
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 304
How many times will the following loop execute? javascript let count = 0; while (count < 5) { count++; }
A. 0
B. 4
C. 5
D. Infinite
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 305
Which of the following is an ordered, indexed data structure in JavaScript?
A. Object
B. Array
C. Set
D. Map
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 306
Which of these statements about Set in JavaScript is true?
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 307
How can you access the value for a specific key in a Map?
A. map[key]
B. map.get(key)
C. map[key].value
D. map.getValue(key)
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 308
What is the result of Array.from(new Set([1, 2, 2, 3, 4]))?
A. [1, 2, 2, 3, 4]
B. [1, 2, 3, 4]
C. [2, 3, 4]
D. [1, 3, 4]
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 309
Which of these data structures does not allow duplicate values by default?
A. Array
B. Object
C. Set
D. Map
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 310
What is a callback function in JavaScript?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 311
Which of the following correctly demonstrates a callback function? javascript function greet(name,
callback) { console.log('Hello ' + name); callback(); } greet('Alice', function() { console.log('Callback
executed'); });
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 312
What is the main advantage of using callbacks in JavaScript?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 313
What is an example of a built-in JavaScript method that uses a callback function?
A. forEach()
B. map()
C. setTimeout()
D. All of the above
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 314
What is a common issue when using callbacks in JavaScript, especially when nesting multiple
callbacks?
A. Callback rejection
B. Callback rejection
C. Callback hell
D. Callback cycle
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 315
Which of the following is a correct syntax for defining a function in JavaScript?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 316
What is the output of the following code? javascript function add(a, b) { return a + b; } console.log(add
(2, 3));
A. Undefined
B. 23
C. 5
D. NaN
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 317
What keyword is used to define an arrow function in JavaScript?
A. =>
B. ->
C. :
D. None of the above
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 318
Which of these functions immediately invokes itself upon definition?
A. Anonymous function
B. Named function
C. IIFE (Immediately Invoked Function Expression)
D. Callback function
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 319
What is the default return value of a function in JavaScript if no return statement is specified?
A. Null
B. Undefined
C. NaN
D. false
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Objects
QUESTION 320
Which of the following is a valid way to create an object in JavaScript?
A. let obj = { }
B. let obj = Object.create()
C. let obj = new Object({ })
Correct Answer: AC
Section: (none)
Explanation
Explanation/Reference:
QUESTION 321
What is the result of the following code? javascript const person = { name: 'Alice', greet: function()
{ return 'Hello ' + this.name; } }; console.log(person.greet());
A. Hello Alice
B. Hello undefined
C. Undefined
D. Throws an error
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 322
Which method is used to get an array of keys in an object?
A. Object.values()
B. Object.keys()
C. Object.entries()
D. Object.list()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 323
How can you prevent modifications to an object in JavaScript?
A. Object.lock()
B. Object.preventExtensions()
C. Object.seal()
D. Object.freeze()
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 324
What will Object.assign() do when used on an object?
A. It merges properties from one or more source objects into a target object
B. It prevents extensions on the object
C. It deep clones the object
D. It deletes all properties in the object
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 325
What is the purpose of semicolons in JavaScript?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 326
What are reserved keywords in JavaScript?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 327
Which of the following is a correct variable name in JavaScript?
A. var 1name
B. var name@
C. var $name
D. var name%
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 328
What is an expression in JavaScript?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 329
What is the output of console.log(2 + '3');?
A. 5
B. 23
C. NaN
D. undefined
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 330
What does the expression 5 == '5' return in JavaScript?
A. true
B. false
C. undefined
D. Throws an error
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 331
Which of the following is not a primitive data type in JavaScript?
A. String
B. Boolean
C. Object
D. Undefined
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 332
What will typeof NaN return in JavaScript?
A. 'undefined'
B. 'number'
C. 'NaN'
D. 'null'
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 333
What does null represent in JavaScript?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 334
Which keyword is used to define a class in JavaScript?
A. define
B. class
C. constructor
D. object
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 335
What is a constructor in a JavaScript class?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 336
How would you create an instance of a class Person in JavaScript?
A. Person.create()
B. let p = new Person()
C. let p = Person()
D. let p = Person.new()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 337
Which keyword declares a block-scoped variable in JavaScript?
A. var
B. let
C. const
D. Both b and c
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 338
What will happen if you try to reassign a const variable?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 339
Which of the following is the correct way to define a global variable?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 340
What is the default return value of a function that does not explicitly return a value?
A. undefined
B. null
C. 0
D. false
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 341
How do you define a function expression in JavaScript?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 342
Which is an example of a higher-order function?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 343
In JavaScript, what does the this keyword refer to in a global context?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 344
What does this refer to in a regular function?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 345
Which of the following is a correct arrow function syntax?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 346
How does this behave differently in arrow functions compared to regular functions?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 347
Which of the following statements about arrow functions is true?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 348
What is block scope in JavaScript?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 349
Which variables are accessible within a function’s scope?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 350
What will array.push(4) do if array = [1, 2, 3]?
A. Returns [1, 2, 3]
B. Adds 4 to the beginning
C. Adds 4 to the end of the array
D. Throws an error
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 351
How do you create a copy of an array in JavaScript?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 352
What is the syntax for using template literals in JavaScript?
A. "string ${variable}"
B. 'string ${variable}'
C. `string ${variable}`
D. None of the above
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 353
Which of the following correctly uses a template literal to embed a variable name?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 354
How do you enable strict mode in JavaScript?
A. use strict;
B. 'strict mode';
C. import 'strict mode';
D. "use strict";
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 355
What is one primary benefit of strict mode in JavaScript?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 356
What will happen if JavaScript encounters an undeclared variable in strict mode?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 357
Which characters are allowed in JavaScript variable names?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 358
What does the typeof operator return for an array in JavaScript?
A. 'object'
B. 'array'
C. 'object[]'
D. 'undefined'
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 359
What will be the output of console.log(5 + 2 * 3);?
A. 21
B. 11
C. 15
D. 17
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 360
Which operator checks for both value and type equality in JavaScript?
A. ==
B. =
C. ===
D. !==
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 361
What does typeof null return in JavaScript?
A. 'null'
B. 'object'
C. 'undefined'
D. 'NaN'
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 362
Which of the following values is falsy in JavaScript?
A. 0
B. ""
C. null
D. All of the above
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 363
How do you check if a variable x is a number?
A. x.isNumber()
B. typeof x === 'number'
C. isNaN(x)
D. typeof x == number
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Classes
QUESTION 364
How do you define a method inside a JavaScript class?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 365
What is inheritance in JavaScript classes?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 366
Which keyword is used to extend a class from another class in JavaScript?
A. inherit
B. extends
C. implement
D. include
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 367
Which keyword should you use to prevent reassignment of a variable?
A. let
B. const
C. var
D. static
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 368
What will console.log(x); output if x is declared with let but not initialized?
A. undefined
B. Throws a reference error
C. null
D. 0
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 369
Which statement correctly declares a constant array?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 370
How do you call a function myFunction with arguments 5 and 10?
A. myFunction{5, 10}
B. myFunction[5, 10]
C. myFunction(5, 10)
D. myFunction: 5, 10
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 371
Which function does not return a value?
A. console.log()
B. Math.max()
C. parseInt()
D. alert()
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 372
What does this refer to in a method of an object?
A. Global object
B. The object itself
C. Window object
D. Undefined
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 373
What does this refer to in a function defined in strict mode?
A. null
B. Global object
C. undefined
D. Window object
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 374
Why can't arrow functions be used as constructors in JavaScript?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 375
Which of the following is true about arrow functions?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 376
What will for(let i = 0; i < 3; i++) { console.log(i); } output?
A. 0123
B. 012
C. 123
D. Nothing
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 377
Which statement immediately stops a loop?
A. break
B. continue
C. return
D. stop
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Scopes
QUESTION 378
What is the primary difference between let and var?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 379
Which keyword will give a variable a block scope?
A. var
B. global
C. let
D. static
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Arrays
QUESTION 380
What does Array.isArray([1, 2, 3]) return?
A. false
B. true
C. undefined
D. null
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 381
How do you find the length of an array in JavaScript?
A. array.size
B. array.length
C. array.length()
D. array.getSize()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 382
How do you insert a variable name into a template literal?
A. Hello + name +
B. 'Hello + ${name}'
C. `Hello ${name}`
D. Hello (name)
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 383
What is the main advantage of template literals over regular strings?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 384
What happens if you assign a value to an undeclared variable in strict mode?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 385
In which way can strict mode be applied to JavaScript code?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 386
What will console.log(x) output if x is not declared in the script but in strict mode?
A. undefined
B. Throws a reference error
C. null
D. It will create the variable automatically
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 387
Which keyword is used to define private properties in a JavaScript class (as of ES2022)?
A. private
B. const
C. # before the property name
D. __ before the property name
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 388
What will typeof function(){} === 'function' return?
A. false
B. true
C. Throws an error
D. undefined
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 389
What is a closure in JavaScript?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference: