ES6 Flashcards
ES6-CONST-LET
What is a code block? What are some examples of a code block?
JavaScript statements can be grouped together in code blocks, inside curly brackets {…}.
The purpose of code blocks is to define statements to be executed together.
Examples: function code block
ES6-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.
ES6-CONST-LET
What is the scope of a variable declared with const or let?
Block scope
The let keyword is similar to the var keyword, except that these variables are blocked-scope.
(are not initialized to any value, and are not attached to the global object)
const keyword are blocked-scope and cannot be redeclared.
ES6-CONST-LET
What is the difference between let and const?
const cannot be reassigned
both are block-scoped variables
ES6-CONST-LET
Why is it possible to .push() a new value into a const variable that points to an Array?
The const keyword ensures that the variable it creates is read-only. However, it doesn’t mean that the actual value to which the const variable reference is immutable.
Cannot reassign the array to another array
ES6-CONST-LET
How should you decide on which type of declaration to use?
var = global scope let = block scope but use if need to reassign const = block scope if read only and no reassignment
ES6-TEMPLATE-LITERALS
What is the syntax for writing a template literal?
Use the backtick to create a string literal for string interpolation variable declaration (let, const, var) = `string ${'Fred'.toUpperCase()} string`; console.log // string FRED string
(JavaScript string interpolation is the process of embedding an expression into part of a string).
${ ‘variable’}
ES6-TEMPLATE-LITERALS
What is “string interpolation”?
String formatting: the ability to substitute part of the string for the values of variables or expressions. This feature is also called string interpolation.
${ variable }
What is destructuring, conceptually?
Destructuring broadly means extracting data from arrays or objects.
Taking the values and assigning them into new variables
const { propKey1: propAlias, propKey2 } = someObject;
const [first, second, third, fourth] = theArray
create an object/array
keyword = [] / {}
destructuring an object/array
keyword [ variables ] = object/array
where the brackets/braces are located (left or right side)
What is the syntax for defining an arrow function?
(param1, param2) => {
return;
}
param => exp;
( ) => exp;
_______________________________________________________________
const functionName = parameter => expression
or const functionName = (param1, param2) => param1 + param2
or const functionName = (param1, param2) => ( {param1:param2} )
When an arrow function’s body is left without curly braces, what changes in its functionality?
function body gets evaluated as an expression
it has an implicit return
How is the value of this determined within an arrow function?
arrow functions have a lexical scope (using global variables) so the value of ‘this’ is determined by the surrounding scope.
takes the this from the enclosing function (parent)
‘this’ is determined when an arrow function is defined (definition time)
i.e. either window if it’s a global scope or local variable if arrow function is wrapped in a regular function
tim : arrow function = ‘this’ is defined at definition time
regular function = ‘this’ is defined at call time
COMMAND-LINE-BASICS
What is a CLI?
Command-line interface (CLI)
A command-line interpreter or command-line processor uses a command-line interface (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 (GUI)
is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicator such as primary notation, instead of text-based UIs, typed command labels or text navigation.
GUIs were introduced in reaction to the perceived steep learning curve of CLIs (command-line interfaces), which require commands to be typed on a computer keyboard.
COMMAND-LINE-BASICS
Give at least one use case for each of the commands listed in this exercise.
* man
man - an interface to the system reference manuals
Ex. man cat // name synopsis description
COMMAND-LINE-BASICS
Give at least one use case for each of the commands listed in this exercise.
* cat
cat - concatenate files and print on the standard output
Example: cat laziness.txt
// shows the text content on the terminal ~
1. Laziness: The quality that makes you go to great effort to reduce overall energy expenditure…