Node.js Flashcards
what is Node.js?
a platform built on Chrome’s JS runtime for easily building fast and scalable network applications.Backend language built with python but mostly C++ and JS. It is for running JS.
what can Node.js be used for?
primarily used for non-blocking, event-driven servers, due to its single-threaded nature. Used for traditional websites and back end API services. Make command line program using node
what is a REPL?
stands for Read Eval Print Loop. it is an interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user. Lets you run JS in your command line. Browser console is also a REPL
when was Node.js created?
created in 2009 by Ryan Dahl. it is a runtime system for creating mostly server side applications
what back end languages have you heard of?
PHP, Ruby, Java, Python, C#(.NET), C++, Pascal, Visual Basic, Pearl, Go, Elixir, Elm ,Rust
what is a computer process?
the instance of a computer program that is being executed by one or many threads. It also contains the program code and its activity. Executed by CPU threads
Roughly how many computer processes are running on your host operating system(Task Manager or Activity Monitor)?
a lot
Why should a full stack Web developer know that computer processes exist?
web dev is all about different programs talking to each other so if two processes are talking to each other, both of them have to be running, therefore you have to know if they are running
What is the process object in a Node.js program?
a global object that can be accessed inside any module without requiring it
How do you access the process object in a Node.js program?
because it is global
What is JavaScript module?
it is a single js file
What values are passed into a Node.js module’s local scope?
__dirname, __filename, exports, required, and module
Give two examples of truly global variables in a Node.js program.
the process object, console object, global object, window object
What is the purpose of module.exports in a Node.js module?
its the instruction that tells Node.js which bits of code such as functions, objects, strings are needed to export from a given file so other files are allowed to access the exported code
How do you import functionality into a Node.js module from another Node.js module?
by calling the require( ) method
What is the JavaScript Event Loop?
it is whats behind JS asynchronous programming. JS executes all operations on a single thread, but uses a few data structures
What is the JavaScript Event Loop?
it is whats behind JS asynchronous programming. JS executes all operations on a single thread, but uses a few data structures. Part of the JS run time that checks for asyncrynous call backs and puts it back on the stack when it is ready
What is different between “blocking” and “non-blocking” with respect to how code is executed?
blocking statements is executed sequentially one after another, while non blocking executes parallel. Blocking is the code thats on the stack. non blocking is things that are happening off the stack
What is a directory?
its a file that points to other files
What is an absolute file path?
sometimes known as the full path, it includes the complete location of the file or folder.
What is an absolute file path?
sometimes known as the full path, it includes the complete location of the file or folder.
What method is available in the Node.js fs module for writing data to a file?
writeFile method
Are file operations using the fs module synchronous or asynchronous?
it is both forms.
What is JSON?
is a syntax for serializing objects, arrays, numbers, strings, booleans, and null.
What is JSON?
Stands for JS Object Notation, is a syntax for serializing objects, arrays, numbers, strings, booleans, and null.
Why are serialization and deserialization useful?
in order to transfer data from one network to another
Why are serialization and deserialization useful?
to convert data into bytes to save data into a hard drive. allows us to store and transmit data.
How do you deserialize a JSON string into a data structure using JS?
with the JSON.parse( ) method
What is a client?
service requesters
What is a client?
service requesters. something that request data from a server. for example your browser. HTTPIE is a python script that makes a request
Which HTTP method does a browser issue to a web server when you visit a URL?
the browser sents an HTTP request to the webserver.
Which HTTP method does a browser issue to a web server when you visit a URL?
the get method.
What is on the first line of an HTTP request message?
a start line which contains 3 elements. An HTTP method(GET, PUT, POST), the request target, usually a URL, last is the protocol(which version of HTTP)
What are HTTP headers?
let the client and the server pass additional information with an HTTP request or response. It consists of case insensitive name followed by a colon : then by its value.
Is a body required for a valid HTTP message?
no it is not
Is a body required for a valid HTTP message?
body is OPTIONAL
What is NPM?
Node Package Manager. the world’s largest Software Library(Registry). consist of 3 components. 1. the website, 2. the command line interface(CLI), 3. the registry
What is package?
a folder containing a program described by a package.json file
How can you create a package.json with npm?
with the npm init –yes or -y command
What is a dependency and how do you add one to a package?
a dependency occurs when one package depends on another. If you need a program or depend on one such as jquery
What happens when you add a dependency to package with npm?
the package.json will update to include the added dependency. and node_modules directory will get created
How do you add express to your package dependencies?
npm install command
What Express application method starts the server and binds it to a network PORT?
app.listen method
How do you mount a middleware with an Express application?
using the app.use method
Which objects does an Express application pass to your middleware to manage the request/ response lifecycle of the server?
the req and res objects
What is the purpose of the Content-Type header in HTTP request and response messages?
to indicate the media type of the resource. It also tells the client what the content type of the returned content is. To tell the client what they are receiving and what the media type of the body is
What does express.static() return?
returns function
What is the local __dirname variable in a Node.js module?
absolute path of file
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json is the Content-Type header
What does express.json( ) middleware do and when would you need it?
it parses incoming request with JSON payloads and is based on body-parser
What does express.json( ) middleware do and when would you need it?
it parses incoming request with JSON payloads and is based on body-parser. Use it when you want to work with a JSON object
What is the significance of an HTTP request’s method?
to indicate the desired action to be performed for a given resource
What is Webpack?
it’s a module bundler and its main purpose is to bundle JS files for usage in a browser.
How do you add a devDependency to a package?
you can install them in the root directory of your package with –save-dev
What is an NPM script?
shell command to give a key as the command to run
How do you execute Webpack with npm run?
npm run build
How are ES Modules different from Common JS modules?
can use the keywords import and export
What kind of modules can Webpack support?
AMD, typescript, css files, an ES2015 import