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. 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
2
Q

What can Node.js be used for?wh

A

Node.js is used for developing applications that make use of the ability to run JavaScript both on the client as well as on the server side.
ex Real time apps , instant messaging / chat apps, streaming app, social media.

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 an interactive shell / computer programming environment that reads user inputs, executes them, and returns the result to the user;

EX: Chrome Browser Console

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

Scripting Langs - Python, Ruby, PHP, JavaScript, Perl, Elixir
(JIT) - just in time compilation
typescript is a good language to learn after bootcamp.

Memory Managed Langs - Java, C#, Kotlin, Golang, Fortan
//These languages are compiled ahead of timt
//garbage collection
Manual Memory Management - C++, C, Swift,
//ahead of time compiled
//low-level
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 object that provides information about, and control over, the current Node.js 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

since it’s a global object it can accessed from anywhere. It can also be accessed using require():

Example: in the exercise we accessed it using console.log().

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

Array of strings

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.

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

exports, require, module, __filename, __dirname

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

Process - process object
Console - used to print stdout and stderr
Buffer - used to handle binary data

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

Module exports are the instructions that tell Node. js which bits of code (functions, objects, strings, etc.) to export from a given file so that other files are allowed to access the exported code.

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
use the require( ) method.
syntax: const varName = require( ' ./filename ' );
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the JavaScript Event Loop?

A

looks at the task queue then pushes it onto the stack when the call stack is clear the next thing in the queue gets pushed into the call stack.

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

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

A

blocking code is anything occupying the call stack. Then we have to wait for it to be cleared.

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

What is a directory?

A

A location for storing files

A.K.A a folder.

17
Q

What is a relative file path?

A

points to a relative file in the current directory. and contains a portion of the full path.

18
Q

What is an absolute file path?

A

starts at the root of the file system, starts with a slash.

19
Q

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

A

the fs module, all methods are asynchronous by default,

20
Q

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

A

fs.writeFile method - used to asynchronously write the specified data to a file.
syntax - fs.writeFile( file, data, options, callback )

21
Q

Are file operations using the fs module synchronous or asynchronous?

A

Every method in the fs module has synchronous as well as asynchronous forms. Asynchronous methods take the last parameter as the completion function callback and the first parameter of the callback function as error.

all the methods are asynchronous by default, but they can also work synchronously by appending Sync .

22
Q

What is Webpack?

A
webpack is a static module bundler for modern JavaScript applications
 it internally builds a dependency graph from one or more entry points and then combines every module your project needs into one or more bundles, 

Webpack is a tool that lets you compile JavaScript modules, also known as module bundler. Given a large number of files, it generates a single file (or a few files) that run your app.

23
Q

How do you add a devDependency to a package?

A

npm install –save-dev

24
Q

What is an NPM script?

A

An npm script is a convenient way to bundle commands for your project.
typically commands that you enter in the terminal that runs something in your application.

25
Q

How do you execute Webpack with npm run?

A

run npm run build in terminal

you need to add the NPM script “build”: “webpack”