Do you know that? 49% of freelancers have not felt the impacts of the economic downturn next

Contact Email: teammmrem@yahoo.com

<< All Upwork (oDesk) and Elance Tests << Upwork (oDesk) test answers << Web Development category

Test answers for Node.js Test 2016

(20) Last updated: March 12
Upwork (oDesk) • Web Development
Questions and answers are regularly updated. Answered and not answered tests questions.

This helps getting job: Hundreds of (cover letter examples , interview questions , profile samples ) • Earn on Upwork (oDesk)
Job assistance: jobs popularityfreelance rates

Popular test answers: HTML, .Net, CSS, English, SEO, Photoshop, iOS, Java, Android, Ruby, Python, JavaScript

See all 6 tests answers updated

Find Upwork (oDesk) and Elance test answers on this website:



Collapse | Expand

20 Answered Test Questions:

1. Which Node.js module can be used to get the IP address of the server the program is running on?

Answers:

• util

• os

• dns

• net

2. What does the following code do?

var http = require('http');
var fs = require('fs');

var file = fs.createWriteStream("file.png");
var request = http.get("http://path/to/file.png", function(response) {
  response.pipe(file);
});

Answers:

• It creates an HTTP GET request and pipes its response into a writeable file stream.

• It creates an HTTP GET request, and synchronously pipes its response into a writeable file stream.

• It creates an HTTP POST request and pipes its response into a readable file stream.

• It creates an HTTP POST request and pipes its response into a writeable file stream.

3. Which of the following methods can be used to write a file in Node.js?

Answers:

• fs.write()

• fs.writeFile()

• fs.createWriteStream()

• fs.writeStream()

4. Which of the following methods will print to the console without a trailing new line?

Answers:

• process.stdout.print()

• console.error()

• console.log()

• process.stdout.write()

5. Which of the following statements is true about the process object in Node.js?

Answers:

• It is a local object.

• It is an instance of the events.EventEmitter class.

• The process.exit(1) method ends the process with a "success" code.

• "process.stderr" and "process.stdout" are non-blocking if they refer to regular files or TTY file descriptors.

6. Which of the following will synchronously check if a file/directory exists?

Answers:

• fs.exists()

• fs.existsSync()

• fs.checkFileSync()

• fs.checkDirSync()

7. Which of the following methods can be used to read the contents of a directory?

Answers:

• fs.readdir()

• fs.readdirSync()

• fs.readDirectory()

• fs.readdirAsync()

8. Which of the following console commands will update all installed global packages to the latest available versions?

Answers:

• npm upgrade -g

• npm install -uga

• npm update -g

• npm version --install-latest

9. Which of the following statements are true about the child_process module in Node.js?

Answers:

• It is not possible to stream data through a child process' stdin, stdout, and stderr in a fully non-blocking way.

• Child processes always have two streams associated with them.

• "require('child_process').spawn()" can be used to create a child process.

• "require('child_process').fork()" can be used to create a child process.

10. Which array contains the command line arguments in Node.js?

Answers:

• process.argv

• args.argv

• arguments.argv

• env.argv

11. Which of the following will copy a file in Node.js?

Answers:

• var fs = require('fs'); fs.createReadStream('test.file').pipe(fs.createWriteStream('newFile.file'));

• var fs = require('fs'); fs.createReadBuffer('test.file').pipe(fs.createWriteBuffer('newFile.file'));

• var fs = require('file'); fs.createFileReader('test.file').pipe(fs.createFileWriter('newFile.file'));

• var fs = require('fs'); fs.createReadBuffer('test.file').stream(fs.createWriteBuffer('newFile.file'));

12. Which of the following statements are true about the module.exports object in Node.js?

Answers:

• It is the object that gets returned from a require() call.

• It can be assigned in a callback.

• Assigning an export object to module.exports will rebind the local exports variable.

• None of these.

13. Which of the following will open a file, then read its contents one line at a time?

Answers:

• fs.readFileStream()

• fs.readFile()

• fs.createReadStream()

• fs.createFileStream()

14. Which of the following NPM commands will install both dependencies and devDependencies of a given project?

Answers:

• npm install

• npm install --dev

• npm install --production

• None of these

15. Which of the following statements is true about the console Object in Node.js?

Answers:

• "console.log" can take only a single argument.

• "console.log" prints to stdout without a newline.

• Its functions are synchronous when the destination is a terminal or a file, and and asynchronous when it's a pipe.

• Its functions are asynchronous when the destination is a terminal or a file, and and synchronous when it's a pipe.

16. What does the following command do?

npm view <package-name> version

Answers:

• It shows the version of the package installed globally.

• It shows the version of the package installed locally.

• It shows the version of the package that is cached.

• It shows the latest version of the package that is available.

17. Which of the following can be used to get the currently running script's path in Node.js?

Answers:

• __filename

• os.tmpdir()

• path.dirname()

• path.basename()

18. Which of the following can be used to access the environment variable, "ENV_VARIABLE" in Node.js?

Answers:

• process.env.ENV_VARIABLE

• process.argv.ENV_VARIABLE

• process.env.var.ENV_VARIABLE

• process.environment.ENV_VARIABLE

19. What does process.argv[1] contain?

Answers:

• node

• The file path of the JavaScript file.

• The first command line argument.

• The second command line argument.

20. Which of the following command-line arguments to "npm install" will allow an NPM package's binaries to be run outside the project folder?

Answers:

• -g

• --global

• -l

• --link