Backend Flashcards
Es-6-const-let
What is a code block? What are some examples of a code block?
Code blocks are denoted by curly braces. Examples are if else, for, do while, while, try catch and so on.
Es-6-const-let
What does block scope mean?
A block scoped variable means that the variable defined within a block will not be accessible from outside the block. A block can reside inside a function, and a block scoped variable will not be available outside the block even if the block is inside a function.
Es-6-const-let
What is the scope of a variable declared with const or let?
Block-scope
Es-6-const-let
What is the difference between let and const?
The const keyword cannot be reassigned, meaning it creates a read-only reference to a value. But the let keyword is mutable, meaning you can change its values anytime.
Es-6-const-let
Why is it possible to .push() a new value into a const variable that points to an Array?
We are not reassigning the value of a variable.
Es-6-const-let
How should you decide on which type of declaration to use?
If you don’t intend to modify the variable, then use the const keyword. Otherwise, use let keyword. Always default const if you are not sure.
Es-6-template-literals
What is the syntax for writing a template literal?
Keyword variable name equal sign backticks with text content.
Es-6-template-literals
What is “string interpolation”?
String interpolation is replacing placeholders with values in a string literal.
Es-6-destructuring
What is destructuring, conceptually?
Es-6-destructuring
What is the syntax for Object destructuring?
Es-6-destructuring
What is the syntax for Array destructuring?
Es-6-destructuring
How can you tell the difference between destructuring and creating Object/Array literals?
Es-6-arrow-functions
What is the syntax for defining an arrow function?
Variable keyword, function name, equal sign, parameters with parenthesis, arrow, function code block with curly braces if there is more than one line let add = (x, y) => x + y; let add = (x, y) => {return x + y};
Es-6-arrow-functions
When an arrow function’s body is left without curly braces, what changes in its functionality?
Implicitly return value
Es-6-arrow-functions
How is the value of this determined within an arrow function?
Refers to window object or global object
Arrow functions do not have their own this.
Whatever this is in the parent scope and it doesn’t create own lexical scope
Command-line-basics
What is a CLI?
Command-line interface
A command-line interpreter or command-line processor uses a CLI to receive commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invoking executables and providing information to them as to what actions they are to perform.
Command-line-basics
What is a GUI?
Graphical user Interface.
A GUI is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicators such as primary notation, instead of text-based UIs, typed command labels or text navigation.
Command-line-basics
Give at least one use case for each of the commands listed in this exercise.
- Man - Show manual page for a command. Look up what a command does
- Cat - concatenate files and print on the standard output
- Ls list directory content. - what directories we have
- Pwd to find out current directory you are in
- Echo - display line of text/string that passed as an argument
- Touch create a blank text file, Before creating a text file, it was used to change file access and modification time
- Mkdir create a new directory(folder)
- Mv - move a file or folder, but also rename the text
- Rm permanently remove a file or directory
- Cp - copy a file and can move to another directory
Command-line-basics
What are the three virtues of a great programmer?
- Laziness: The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful and document what you wrote so you don’t have to answer so many questions about it.
- Impatience: The anger you feel when the computer is being lazy. This makes you write programs that don’t just react to your needs, but actually anticipate them. Or at least pretend to.
- Hubris: The quality that makes you write (and maintain) programs that other people won’t want to say bad things about.
Node-Intro
What is Node.js?
Node.js is a program that allows JavaScript to be run outside of a web browser.
Node-Intro
What can Node.js be used for?
Node.js can be used to build back ends for web applications, command-line programs or any kind of automation that developers wish to perform.
Node-Intro
What is a REPL?
Read-Evaluate-Print-Loop
Node-Intro
When was Node.js created?
May 27, 2009
Node-Intro
What back end languages have you heard of?
C++, C#, Ruby, PHP
Node-process-argv
What is the process object in a Node.js program?
The process object is a global that provides information about, and control over, the current Node.js process.
Node-process-argv
How do you access the process object in a Node.js program?
Type the process
Node-process-argv
What is the data type of process.argv in Node.js?
Array
Node-module-system
What is a JavaScript module?
It is a single .js file
Each file considers own module
Node-module-system
What values are passed into a Node.js module’s local scope?
Exports, require, module, __filename, __dirname
Node-module-system
Give two examples of truly global variables in a Node.js program.
process and console
Node-require
What is the purpose of module.exports in a Node.js module?
Assign a value and use it at some other file.
Node-require How do you import functionality into a Node.js module from another Node.js module?
Use require function and call the .js file
The-event-loop
What is the JavaScript Event Loop?
Look at the stack and task queue, if the stack is empty, it pushes callback to the stack
The-event-loop
What is different between “blocking” and “non-blocking” with respect to how code is executed?
Blocking- slow, block the execution of JavaScript until a certain long task has finished
When blocking, prevent anything from happening. Nothing can happen.
Non-blocking is the asynchronous that it wouldn’t block and accept call back function
Push off to the side so that other codes can work.
node-fs-readfile
What is a directory?
Folder that contains multile files
node-fs-readfile
What is a relative file path?
file on the current working directory