Q26. How do you
make
an HTTP server object active and listen to requests on certain ports?
server. start
server.activate
server.listen
server. run
Q27. What does the code shown below do?
const fs = require('fs'); const os = require('os');
const system = os.platform(); const user = os.userInfo().username;
fs.appendFile('hello.txt', `Hello ${user} on ${system}`, (err) => { if (err) throw err; console.log('The data was appended to file!');}
);
creates a text file hello.txt and appends customized text
creates an image file
console logs system information
creates a file named data and append numbers
Q28. How do you start a Node
application,
if the entry file is indexjs?
nodemon start
start index.js
node index.js
node start
Q29. What is the purpose of the file system (fs)
module?
to provide methods to work with requests and responses
Q44. According to the rules of semantic versioning, what does a release incrementing the third number in an npm
version string communicate to users about the release changes?
Changes are not backwards compatible.
Changes might not be backward compatible and might break existing code.
Changes are just bug fixes and no new features were added.
Changes will add new functionality but will not break any existing code.
Q45. What does REPL stand for?
run, examine, put, loop
read, eval, print, loop
run, edit, print, loop
read, extend, print, loop
Q46. Which file does node-gyp
use
to read the build configuration of a module?
.gyprc
binding.gyp
gyp.json
package.gyp
Q47. Which core module in Node can you use for
testing?
chai
jest
assert
mocha
Q48. Which core module in Node provides an API to register callbacks to track asynchronous resources created
inside
a Node.js application?
Q55. You have to read a large text file, replace some words in it, and write it back to a new file. You know
that
the memory on your target system is limited. What should you do?
Use regular expressions directly on the file.
Use Promises and async/await to offload the task to libuv.
Copy the file into a database and perform the operations there.
Use readline together with streams to read and transform and
write the file contents line by line.
Q68. How does it affect the performance of a web application when an execution path contains a CPU-heavy
operation,
such as calculating a long Fibonacci sequence?
As Node.js is asynchronous, this is handled by a libuv and a threadpool.
The
performance will not notably degrade.
As the application code runs asynchronously within a single thread, the
execution will block, accepting no more requests until the operation is completed.
As Node.js is asynchronous, this is handled by a threadpool and the
performance will not notably degrade.
The current thread will block until the execution is
completed
and the operating system will spawn new threads to handle incoming requests. This can exhaust the number of
allowed threads (255) and degrade performance over time.
Q69. What is used for parsing and running
Javascript in Node.js?
Q76. When you
require(something), where will Node.js attempt to resolve(something)?
the local .modules folder, then the parents' node_modules folder
the local node_modules folder, then the parents'
node_modules
folder
the .modules folder under the home directory
a "something.js" file or a "something" folder, which
exist on the same level as the requiring file
Q77. An external library has its own codebase and license. It is not managed by the Node.js core team. Which
choice
is an external library that Node.js uses?