PLAY READ BLOG

Assess your experience with Node.js

I estimate it would take you 39 steps in 12 minutes to Assess your experience with Node.js.
Which of the following is Node's way to work with an asynchronous method that exposes "data"?
1.
asyncMethod((err, data) => {
// Continue execution after asyncMethod is done
}, params);

2.
asyncMethod(params, (err, data) => {
// Continue execution after asyncMethod is done
});

3.
var data = asyncMethod(params);
// Continue execution after asyncMethod is done

4.
asyncMethod(params).callback((err, data) => {
// Continue execution after asyncMethod is done
});
  • 1.
  • 2.
  • 3.
  • 4.
Which code below will copy "big.file" as "big.file.copy" without buffering the content of big.file into memory?
Assume that big.file is a few GB and your Node process is limited to a few 100 MB. Assume that the fs module is already required.
1.
fs.createReadStream("./big.file").pipe(fs.createWriteStream("./big.file.copy");

2.
fs.createStream("./big.file").pipe(fs.createStream("./big.file.copy");

3.
fs.readFilePromise("./big.file").then(fs.writeFilePromise("./big.file.copy");

4.
fs.readFile("./big.file").then(fs.appendFile("./big.file.copy");
  • 1.
  • 2.
  • 3.
  • 4.
What's true about the arguments passed to the request listener function in the http module (usually named req and res)
1. Both req and res are Readable Streams

2. Both req and res are Duplex Streams

3. req is a Readable Stream. res is a Writeable Stream

4. req is a Writable Stream. res is a Readable Stream

5. Both req and res are Writable Streams
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
Here's a simple unit test to test Node's util.types.isDate method. You can run this test in a REPL session:

// 1st
const date = new Date();
const notDate = 'Just a String';

// 2nd
const dateTest = util.types.isDate(date);
const notDateTest = util.types.isDate(notDate);

// 3rd
assert.ok(dateTest);
assert.ok(!notDateTest);
What labels correctly describe what the 1st, 2nd, and 3rd sections above do?
  • Setup, Expect, Print
  • Arrange, Act, Assert
  • Act, Assert, Arrange
  • Setup, Act, Arrange
Within a Node.js module file, how can you access the full path to where the file is located (without the file name itself)

So if the file you are executing with Node is:: /users/home/pluralsight/index.js

What you need to use is: /users/home/pluralsight
  • __cwd
  • __path
  • __filePath
  • __filename
  • __dirname
When does a function reference gets pushed to the VM Call Stack?
1. Only when you invoke the function recursively

2. When the function is defined

3. Every time that function is invoked

4. Every time the function returns
  • 1.
  • 2.
  • 3.
  • 4.
Which console method can be used to print the Call Stack status for a given line in the code?
  • console.dir
  • console.trace
  • console.error
  • console.debug
  • console.info
What does the -D flag mean when your run npm install?
For example: npm i -D lodash
1. Only go through a DRY RUN and don't actually install the package

2. Install the package as a development dependency

3. Output debug information while installing the package
  • 1.
  • 2.
  • 3.
Which built-in Node.js module can be used to register callbacks tracking the lifetime of asynchronous resources created inside a Node.js application?
  • perf_hooks
  • child_process
  • domain
  • async_hooks
  • stream
💡FUN FACT 💡As of 2019, 98% of Fortune 500 companies use Node.js regularly. It also wins as most loved framework (73.4% of developers love Node) and it’s the second most-demanded coding skill by employers.
How do you require the built-in module "net" in Node.js?
  • const net = script.src('net');
  • import('net') as net;
  • require('net') as net;
  • const net = include('net');
  • const net = require('net');
Essentially, console.log('something') is equivalent to:
1. process.stdout.log('something\n');

2. process.stdin.write('something\n');

3. process.stdout.write('something\n');

4. process.stdin.log('something\n');
  • 1.
  • 2.
  • 3.
  • 4.
What happens when you issue the command "npm install" in a node project?
1. npm will try to find a package.json file to find out what dependencies to install

2. Nothing: the command has to be npm install package-name

3. npm will find out what packages you depend on by scanning the code for require() calls

4. npm will install the most recent version of itself

5. npm will read the project dependencies from a .packagerc file and install them
  • 1.
  • 2.
  • 3.
  • 4.
What's the problem with using self-signed SSL certificates?
1. They do not use a strong encryption algorithm

2. They cannot be used with NODE_ENV is set to "production"

3. They are not trusted by browsers
  • 1.
  • 2.
  • 3.
Given:

const http = require('http');

What does http.get do?
1. http.get is not a valid method or property on the http module

2. It performs an http GET request

3. It mounts the http server on /get

4. It defines an http GET route
  • 1
  • 2.
  • 3.
  • 4.
How do you print a message to the standard output stream (stdout) from a Node process?
  • print('MESSAGE');
  • console.print('MESSAGE');
  • new Console('MESSAGE');
  • console.log('MESSAGE');
What Node CLI option can be used to execute a JavaScript string and print its result to the screen?
  • -e
  • -r
  • -p
  • -c
With:

node script.js arg1 arg2 arg3

How can you access the arguments values from within script.js?
  • PROCESS_ARGV
  • process.argv
  • os.argv
  • cli.argv
Which NPM command can be used to download all the project's dependencies and save them under a local node_modules folder?
  • save
  • start
  • download
  • install
  • run
93% of all 134 users completed this intention.
Get Started   

Or consider 77 other intentions.