What does process.argv[1] contain?
node 5.0%
The file path of the JavaScript file. 78.0%
The first command line argument. 5.0%
The second command line argument. 10.0%
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(respon...
It creates an HTTP GET request and pipes its response into a writeable file stream. 100.0%
It creates an HTTP GET request, and synchronously pipes its response into a writeable file stream. 0.0%
It creates an HTTP POST request and pipes its response into a readable file stream. 0.0%
It creates an HTTP POST request and pipes its response into a writeable file stream. 0.0%
What does the following command do? npm view <package-name> version
It shows the version of the package installed globally. 0.0%
It shows the version of the package installed locally. 10.0%
It shows the version of the package that is cached. 0.0%
It shows the latest version of the package that is available. 90.0%
Which array contains the command line arguments in Node.js?
process.argv 100.0%
args.argv 0.0%
arguments.argv 0.0%
env.argv 0.0%
Which Node.js module can be used to get the IP address of the server the program is running on?
util 0.0%
os 96.0%
dns 0.0%
net 3.0%
Which of the following can be used to access the environment variable, "ENV_VARIABLE" in Node.js?
process.env.ENV_VARIABLE 100.0%
process.argv.ENV_VARIABLE 0.0%
process.env.var.ENV_VARIABLE 0.0%
process.environment.ENV_VARIABLE 0.0%
Which of the following can be used to get the currently running script's path in Node.js?
__filename 96.0%
os.tmpdir() 0.0%
path.dirname() 3.0%
path.basename() 0.0%
Which of the following command-line arguments to "npm install" will allow an NPM package's binaries to be run outside the project folder?
-g 66.0%
--global 28.0%
-l 2.0%
--link 2.0%
Which of the following console commands will update all installed global packages to the latest available versions?
npm upgrade -g 0.0%
npm install -uga 0.0%
npm update -g 100.0%
npm version --install-latest 0.0%
Which of the following methods can be used to read the contents of a directory?
fs.readdir() 53.0%
fs.readdirSync() 46.0%
fs.readDirectory() 0.0%
fs.readdirAsync() 0.0%
Which of the following methods can be used to write a file in Node.js?
fs.write() 32.0%
fs.writeFile() 36.0%
fs.createWriteStream() 28.0%
fs.writeStream() 1.0%
Which of the following methods will print to the console without a trailing new line?
process.stdout.print() 3.0%
console.error() 0.0%
console.log() 0.0%
process.stdout.write() 96.0%
Which of the following NPM commands will install both dependencies and devDependencies of a given project?
npm install 67.0%
npm install --dev 11.0%
npm install --production 17.0%
None of these 2.0%
Which of the following statements are true about the child_process module in Node.js?
It is not possible to stream data through a child process' stdin, stdout, and stderr in a fully non-blocking way. 4.0%
Child processes always have two streams associated with them. 0.0%
"require('child_process').spawn()" can be used to create a child process. 43.0%
"require('child_process').fork()" can be used to create a child process. 51.0%
Which of the following statements are true about the module.exports object in Node.js?
It is the object that gets returned from a require() call. 69.0%
It can be assigned in a callback. 6.0%
Assigning an export object to module.exports will rebind the local exports variable. 24.0%
None of these. 0.0%
Which of the following statements is true about the console Object in Node.js?
"console.log" can take only a single argument. 27.0%
"console.log" prints to stdout without a newline. 0.0%
Its functions are synchronous when the destination is a terminal or a file, and and asynchronous when it's a pipe. 72.0%
Its functions are asynchronous when the destination is a terminal or a file, and and synchronous when it's a pipe. 0.0%
Which of the following statements is true about the process object in Node.js?
It is a local object. 0.0%
It is an instance of the events.EventEmitter class. 90.0%
The process.exit(1) method ends the process with a "success" code. 10.0%
"process.stderr" and "process.stdout" are non-blocking if they refer to regular files or TTY file descriptors. 0.0%
Which of the following will copy a file in Node.js?
var fs = require('fs'); fs.createReadStream('test.file').pipe(fs.createWriteStream('newFile.file')); 100.0%
var fs = require('fs'); fs.createReadBuffer('test.file').pipe(fs.createWriteBuffer('newFile.file')); 0.0%
var fs = require('file'); fs.createFileReader('test.file').pipe(fs.createFileWriter('newFile.file')); 0.0%
var fs = require('fs'); fs.createReadBuffer('test.file').stream(fs.createWriteBuffer('newFile.file')); 0.0%
Which of the following will open a file, then read its contents one line at a time?
fs.readFileStream() 4.0%
fs.readFile() 4.0%
fs.createReadStream() 90.0%
fs.createFileStream() 0.0%
Which of the following will synchronously check if a file/directory exists?
fs.exists() 0.0%
fs.existsSync() 94.0%
fs.checkFileSync() 5.0%
fs.checkDirSync() 0.0%
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);
});
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.
Which of the following file extensions supports Node Module System ?
.js
.json
.node
All of these
Which following functions are partially buffered?
fs.read()
fs.readSync()
fs.readFile()
fs.readFileSync()
Which of the following is the result of module.id ?
file name
3-byte machine identifier
2-byte process id
3-byte process id
Which of the following variables you can use in modules?
__filename
__directory
__dirname
__filesize
You have a file rect.js with the following contents, What would be the appropriate ways to call the exported function?
module.exports = function area(a, b) {
return a*b;
}
var rect = require('./rect.js);
var area = rect(3);
var rect = require('./rect.js);
var area = rect.area(3);
var area = require('./rect.js')(3);
var area = require('./rect.js').area(3);
Which module of core node.js API is used for writing unit tests for your applications?
assert
should
mocha
jsUnit
Which of the following will remove a file from your file system?
var cb = function(err) { if (err) throw err; console.log('success deleting file'); }
require('fs').remove('filename', cb);
var cb = function(err) { if (err) throw err; console.log('success deleting file'); }
require('fs').rm('filename', cb);
var cb = function(err) { if (err) throw err; console.log('success deleting file'); }
require('fs').unlink('filename', cb);
require('fs').removeSync('filename', cb);
console.log('success deleting file');
Which of the libs are exists in Node Core Libraries?
What happens when executing the following code?
assert = require('assert');
assert(false, 'assert false');
assert throws an AssertionError, program execution stops
assert throws an AssertionError, program execution continues
'assert false' is printed to console, program execution continues
assertion fails, 'assert false' is printed to console, program execution stops
Which of the following template engines is working with Express.js?
HAML
EJS
Handlebars
All of these
Which of the following names is second param of res.render method?
locals
callback
maxAge
cacheControl
Which of the following keywords is used to achieve await-like behaviour?
yield
yields
async
async-await
Which of the following is correct while using a Node module http in a Node based application?
A. var http = import("http");
B. package http;
C. import http;
D. var http = require("http");
Which of the following frameworks is most popular Node.js framework?
Koa
Express
Hapi
Total.js
Which of the following implements stream.Readable interface?
http.IncomingMessage
fs.ReadStream
net.Socket
process.stdin
process.stdout
How would you get the name of the JavaScript file being executed?
process.argv[1]
__filename
process.__filename
__dirname + __filename
Which following code is valid to convert a buffer buf to JSON object?
A. buf.toJSON()
B. buf.json()
C. buf.covertToJson()
D. buf.jsonify()
Which of the following classes is the parent for repl.REPLServer class?
REPL.Interface
readline.Interfase
REPL
REPLSERVER
Which following code is valid to print the current operating system?
A. console.log(os.type);
B. console.log(os.type());
C. console.log(os.getType());
D. None of the above
E. All of the above
How would you get operating system name?
os.type();
os.arch();
os.platform();
os.name();
Which of the following libraries are used for mocking modules?
Rewire
Mockery
Stub
All of these
Which of the following events are emitted by the Readable Stream?
'data'
'end'
'error'
'response'
'drain'
Which of the following engine built of NodeJS framework/platform?
Firefox's JavaScript V8 Engine
Google Chrome's JavaScript V8 Engine
None of above
You would like to inherit the prototype methods from one constructor into another. How could that be accomplished with core node.js functionality?
var util = require("util");
util.inherits(MyClass, SuperClass);
var util = require("util");
util.extend(MyClass, SuperClass);
It is not possible to handle composition (inheritance) with core node.js
var util = require("util");
util.inherits(SuperClass, MyClass);
Which following command ___ shows version of Node?
A. $ npm --version
B. $ node --version
C. $ npm getVersion
D. $ node getVersion
E. None of the above
Which following code is valid to get a joint path?
A. path.join('/test0', 'test11', '2slashes/1slash', 'tab', '..')
B. path.combine('/test0', 'test11', '2slashes/1slash', 'tab', '..')
C. buffer.join('/test0', 'test11', '2slashes/1slash', 'tab', '..')
D. None of the above
Which of the following modules is required to create server for NodeJS?
How can you stop reading from stdin?
process.stdin.pause();
process.stdin.end();
process.stdin.close();
process.stdin.stop();
Which of the following is operates asynchronous logic?
Callbacks
Loops
Event Emitters
All of the above
Which of the following flags working with npm?
Which of the following methods can be used to write a file in Node.js? (check all that apply)
fs.write()
fs.writeFile()
fs.createWriteStream()
fs.writeStream()
Which command enables you to input data using keyboard into your node application?
process.stdin.resume();
process.stdin.pause();
console.read();
console.readln();