Node.js Flashcards

1
Q

What is Node.js?

A

Node.js is a program that allows JavaScript to be run outside of a web browser.

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

Node.js 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

read–eval–print loop (REPL) is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user

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

When was Node.js created?

A

2009 by Ryan Dahl

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
PHP(scripting), Python(scripting), Ruby(scripting), 
C#(compiled), 
C++(compiled), 
Java (compiled),
Swift(compiled/scripting), objective-c (compiled) , perl(scripting),
javascript(script),
go (complied),
erlang(compiled),
elixir (compiled)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a CLI?

A

A Command Line Interface (CLI) processes commands to a computer program in the form of lines of text.

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

What is GUI?

A

A Graphical User Interface (GUI) is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indications instead on text based user interfaces

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

Give at least one use case for - man - command

A

To look up the user manual for any command (name, synopsis, description)

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

Give at least one use case for - cat - command

A
  1. Print files on the standard output.
  2. Concatenate files - combine the contents of those files.
  3. Combine files and write the result to a new file using >
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Give at least one use case for - ls - command

A

Display/print list directory contents

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

Give at least one use case for - pwd - command

A

Display/print the full file name of the current working directory

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

Give at least one use case for - echo - command

A

Display a line of text / Echo/print the line of text to the standard output

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

Give at least one use case for - touch - command

A
  1. make a file

2. update the access and modification times of each file to the current time

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

Give at least one use case for - mkdir - command

A

Make directories

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

Give at least one use case for - mv - command

A
  1. Move files

2. Rename files

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

Give at least one use case for - rm - command

A

Remove files or directories - is instantaneous and permanent

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

Give at least one use case for - cp - command

A

Copy files and directories

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

What is a computer process?

A

A process is the instance of a computer program that is being executed by one or many threads. It contains the program code and its activity. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently.

While a computer program is a passive collection of instructions, a process is the actual execution of those instructions. Several processes may be associated with the same program.

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

Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?

A

400+

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

Why should a full stack Web developer know that computer processes exist?

A

Full stack Web development is based on making multiple processes work together to form one application, so having at least a cursory awareness of computer processes is necessary

21
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.

22
Q

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

A

Process is a global object so you can just reference it - console.log(process)

23
Q

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

A

An array of strings

24
Q

How to you write to the standard out of a Node.js program

A

use console.log( )

25
What is a JavaScript module?
In JavaScript, a "module" is a single .js file.
26
What values are passed into a Node.js module's local scope?
exports, require( ), module, __filename, __dirname,
27
Give 2 examples of truly global variables in a Node.js program
Console, global, process, setInerval/Timeout and clearInterval/Timeout
28
What is the purpose of module.exports in a Node.js module?
Module exports are the instruction that tells Node.js which bits of code (functions, objects, strings, etc.) to “export” from a given file so other files are allowed to access the exported code
29
How do you import functionality into a Node.js module from another Node.js module?
const variable = require(./relativeFilePath )
30
What is the JavaScript Event Loop?
The Event Loop takes callbacks from the callback queue and pushes them to the stack as long as the stack is clear.
31
What is different between "blocking" and "non-blocking" with respect to how code is executed?
"blocking" means script that is executed on the stack, It is "blocking" as long as it is on the stack. It is "non-blocking" when it's not on the stack
32
What is a directory?
A special type of file whose whole job is to point to other files... a folder
33
What is a relative file path?
A path to a file based of the current location (does not start with a /)
34
What is an absolute file path?
The whole file path starting with a slash (the root)
35
What module does Node.js include for manipulating the file system?
The fs module
36
What method is available in the Node.js fs module for writing data to a file?
fs.writeFile( ) method
37
Are file operations using the fs module synchronous or asynchronous?
fs.writeFile( ) is asynchronous. All file system operations have synchronous and asynchronous forms.
38
What is NPM
NPM is a website, a command line interface, ; a software registry that allows developers to share their code so others can reuse that code.
39
What is a package?
A package is a bit of reusable code - it's a file in a directory with one or more files in it including a file called package.json with meta data about this package
40
How can you create a package.json with npm?
On the command line navigate to the rood directory f you package. Then use the npm init command with the --yes or -y flag
41
What is a dependency and how to you add one to a package?
A dependency is a package needed for your application to work, and you add one with the npm install command
42
What happens when you add a dependency to a package with npm?
1. Your package.json file gets updated with the dependency added under dependencies property. 2. The content of that package gets downloaded from the npm registry and put in a node_modules directory
43
What is Webpack?
Webpack is a tool that lets you bundle your JavaScript applications.
44
How do you add a devDependency to a package?
"devDependencies": Packages that are only needed for local development and testing. npm install package-name --save-dev OR npm install package-name -D
45
What is an NPM script?
The "scripts" property of of your package.json file supports a number of built-in scripts and their preset life cycle events as well as arbitrary scripts. scripts are command line commands
46
How do you execute Webpack with npm run?
Add "build": "webpack" to your package.json scripts property then use command -- npm run build
47
How are ES Modules different from CommonJS modules?
ES Modules syntax is more compact than CommonJS, structure can be statically analyzed, the support for cyclic dependencies is better than CommonJS
48
What kind of modules can Webpack support?
ECMAScript modules, AMD Modules, CommonJS
49
How can you make webpack automatically recompile your JSX code whenever changes are made?
Add the script "watch": "webpack --watch --mode=development --devtool=source-map" to your package.json