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
Q

What is a JavaScript module?

A

In JavaScript, a “module” is a single .js file.

26
Q

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

A

exports, require( ), module, __filename, __dirname,

27
Q

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

A

Console, global, process, setInerval/Timeout and clearInterval/Timeout

28
Q

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

A

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
Q

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

A

const variable = require(./relativeFilePath )

30
Q

What is the JavaScript Event Loop?

A

The Event Loop takes callbacks from the callback queue and pushes them to the stack as long as the stack is clear.

31
Q

What is different between “blocking” and “non-blocking” with respect to how code is executed?

A

“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
Q

What is a directory?

A

A special type of file whose whole job is to point to other files… a folder

33
Q

What is a relative file path?

A

A path to a file based of the current location (does not start with a /)

34
Q

What is an absolute file path?

A

The whole file path starting with a slash (the root)

35
Q

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

A

The fs module

36
Q

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

A

fs.writeFile( ) method

37
Q

Are file operations using the fs module synchronous or asynchronous?

A

fs.writeFile( ) is asynchronous. All file system operations have synchronous and asynchronous forms.

38
Q

What is NPM

A

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
Q

What is a package?

A

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
Q

How can you create a package.json with npm?

A

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
Q

What is a dependency and how to you add one to a package?

A

A dependency is a package needed for your application to work, and you add one with the npm install command

42
Q

What happens when you add a dependency to a package with npm?

A
  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
Q

What is Webpack?

A

Webpack is a tool that lets you bundle your JavaScript applications.

44
Q

How do you add a devDependency to a package?

A

“devDependencies”: Packages that are only needed for local development and testing.

npm install package-name –save-dev
OR
npm install package-name -D

45
Q

What is an NPM script?

A

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
Q

How do you execute Webpack with npm run?

A

Add “build”: “webpack” to your package.json scripts property then use command – npm run build

47
Q

How are ES Modules different from CommonJS modules?

A

ES Modules syntax is more compact than CommonJS, structure can be statically analyzed, the support for cyclic dependencies is better than CommonJS

48
Q

What kind of modules can Webpack support?

A

ECMAScript modules, AMD Modules, CommonJS

49
Q

How can you make webpack automatically recompile your JSX code whenever changes are made?

A

Add the script
“watch”: “webpack –watch –mode=development –devtool=source-map”
to your package.json