Senior Side Flashcards
What is a code block? What are some examples of a code block?
A code block is code grouped together with curly braces. Examples of this are after an if statement, for loop, or while loop. The code that will be executed if those conditions are met, or code to execute while we are iterating through the loop.
What does block scope mean?
Block scope means anytime there is a block of code within curly brackets, it’s going to create a specific environment for that particular code block.
What is the scope of a variable declared with const or let?
They are both block scope
What is the difference between let and const?
Let allows reassignment, while const cannot be reassigned.
Why is it possible to .push() a new value into a const variable that points to an Array?
Because you’re changing the value of the array the const variable points to
How should you decide on which type of declaration to use?
Use let when you know the value of the variable will change, and use const for every other variable.
What is the syntax for writing a template literal?
Variable declaration, variable name, assignment operator, opening backtick, string, closing backtick.
What is “string interpolation”?
The ability to substitute part of the string for the values of variables or expressions
What is destructuring, conceptually?
extracting data from arrays and objects and assign them to variables
What is the syntax for Object destructuring?
Keyword for variable declaration, opening curly bracket, property name, colon, variable name, assignment operator, object name you’re destructuring from
What is the syntax for Array destructuring?
Keyword for variable declaration, opening square bracket, variable name, closing square bracket, assignment operator, name of array you’re destructuring
How can you tell the difference between destructuring and creating Object/Array literals?
if the curly braces or square brackets are on the left hand side of the assignment operator, it’s destructuring. If they’re on the right it’s creation.
For destructuring, what questions should you ask?
const { title: book1Title, author: book1Author, libraryID: book1LibraryID } = book1
What is being destructured?
example: title, author and libraryID
Where is it being destructured from?
example: From the book object
What is it being assigned to?
example: assigned to const variables title, author, and libraryID
What is the syntax for defining an arrow function?
Opening parentheses, parameter list, closing parentheses, arrow, expression wrapped in curly braces
When an arrow function’s body is left without curly braces, what changes in its functionality?
Implicit return
How is the value of this determined within an arrow function?
The value of this is determined when the arrow function is DEFINED, not when it’s CALLED
What is a CLI?
A command line interface, which receives commands from a user in the form of lines of text
What is a GUI?
A graphical user interface, which allows users to interact with electronic devices through graphical icons
Give at least one use case for each of the commands listed
Man - read the manual of any given command
Cat - concatenate files and prints them to your terminal
Ls - list the contents of a directory
Pwd - prints the current working directory
Echo - displays a line of text (think console.log for command line)
Touch - update timestamps to the file and creates a file
Mkdir - make a new directory
Mv - move or rename files
Rm - remove files or directories
Cp - copy files and directories
What is Node.js?
program that allows JavaScript to be run outside of a web browser
What can Node.js be used for?
to build back ends for Web applications, scalable systems, command-line programs, or any kind of automation that developers wish to perform
What is a REPL?
Read-Eval-Print Loop. It’s a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user (example: Google Dev Tools)
When was Node.js created?
May 27th, 2009
What back end languages have you heard of?
Scripting - Python, JavaScript, Ruby, PHP, Perl
Compiled - C, C++, Golang, Haskell, Crystal, Rust
Partially compiled (jvm) - Java, Scala, Clojure, Kotlin
Partially compiled (.net clr) - C#, F#
What is the process object in a Node.js program?
a global object that provides information about, and control over, the current Node.js process.
How do you access the process object in a Node.js program?
By using require(‘process’), or you can grab it out of thin air since it’s global
What is the data type of process.argv in Node.js?
An array of strings
What is a JavaScript module?
Blocks of encapsulated code that communicates with an external application on the basis of their related functionality
What values are passed into a Node.js module’s local scope?
Exports, require, module, _filename, _dirname
Give two examples of truly global variables in a Node.js program.
Console and process
What is the purpose of module.exports in a Node.js module?
To make values and functionality available to other modules
How do you import functionality into a Node.js module from another Node.js module?
Using module.exports to be able to export to another module, then use require with the relative path in string format
What is the JavaScript Event Loop?
a runtime model that is responsible for executing the code, collecting and processing events, and executing queued tasks
What is different between “blocking” and “non-blocking” with respect to how code is executed?
Blocking refers to operations that block further execution until that operation finishes while non-blocking refers to code that doesn’t block execution
What is a directory?
A collection of a group of files
What is a relative file path?
A file path that that is relative to the current directory you’re working in
What is an absolute file path?
A file path contains the root element and the complete directory list required to locate the file
What module does Node.js include for manipulating the file system?
Fs module
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?
Both. You get to pick.
What is a client?
A piece of hardware or software the sends requests to servers
What is a server?
A piece of hardware or software that sends responses to clients
Which HTTP method does a browser issue to a web server when you visit a URL?
GET
What is on the first line of an HTTP request message?
HTTP Method (GET, POST), target (URL), HTTP version
What is on the first line of an HTTP response message?
Protocol version, status code, and status text