Node Flashcards

1
Q

What is Node.js?

A

Node.js is a program that allows JavaScript to be run outside of a web browser. It is commonly used to build back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform. Node.js is powered by V8; the same JavaScript engine in the Google Chrome browser. It is free, open-source software and its source code is available on GitHub.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What can Node.js be used for?

A

It is commonly used to build back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a REPL?

A

A read–eval–print loop (REPL), also termed an interactive toplevel or language shell, is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user; a program written in a REPL environment is executed piecewise.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When was Node.js created?

A

May 27, 2009

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What back end languages have you heard of?

A

C++, Python, Java, C# (.net is a framework for C#), Ruby, PHP, Go, Perl, JavaScript/Node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the process object in a Node.js program?

A

The process object is a global that provides information about, and control over, the current Node.js process. As a global, it is always available to Node.js applications without using require( ). It can also be explicitly accessed using require( ):

const process = require(‘process’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you access the process object in a Node.js program?

A

const process = require(‘process’);

And by typing ‘process’ because it is a global variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the data type of process.argv in Node.js?

A

An array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a JavaScript module?

A

In JavaScript, a “module” is a single .js file. Node.js supports modules using a system heavily influenced by CommonJS. Most non-trivial Node.js programs are made of many, many modules. Authors of Node.js programs strive to separate their code into modules that each provide a small chunk of functionality. The program as a whole is the result of all of these modules working together in concert.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What values are passed into a Node.js module’s local scope?

A

__dirname
__filename
exports
module
require

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Give two examples of truly global variables in a Node.js program.

A

clearImmediate(immediateObject)

clearInterval(intervalObject)

clearTimeout(timeoutObject)

console

global

process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the purpose of module.exports in a Node.js module?

A

import functionality into a node.js module from another node.js module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you import functionality into a Node.js module from another Node.js module?

A

module.exports = (name of function you want to export)

require(‘./name of file you want to import’) in the receiving file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a directory?

A

An organizational structure to store files as a group. A directory is a location for storing files on your computer. Directories are found in a hierarchical file system, such as Linux, MS-DOS, OS/2, and Unix.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a relative file path?

A

A relative path refers to a location that is relative to a current directory. Relative paths make use of two special symbols, a dot (.) and a double-dot (..), which translate into the current directory and the parent directory. Double dots are used for moving up in the hierarchy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is an absolute file path?

A

An absolute path is defined as the specifying the location of a file or directory from the root directory(/). In other words we can say absolute path is a complete path from start of actual filesystem from / directory.

17
Q

What module does Node.js include for manipulating the file system?

A

The fs (file system) module

18
Q

What method is available in the Node.js fs module for writing data to a file?

A

fs.writeFile

19
Q

Are file operations using the fs module synchronous or asynchronous?

A

Asynchronous - we know that they are asynchronous because they use a callback function