es6 Flashcards

1
Q

What is a code block? What are some examples of a code block?

A

code block is a group of code put together to be executed. There are function code blocks, css ruleset code blocks, conditional code blocks… etc

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

What does block scope mean?

A

value of the variable is particular to that specific block. the value of the variable only changes in that block, but the original value does not change. Because the let keyword declares a block-scoped variable, the x variable inside the if block is a new variable and it shadows the x variable declared at the top of the script.

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

What is the scope of a variable declared with const or let?

A

They are both blocked-scope variables. They are neither global or local.

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

What is the difference between let and const?

A

block-scoped variables declared by the const keyword can’t be reassigned. the variables declared by the let keyword are mutable.

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

Why is it possible to .push() a new value into a const variable that points to an Array?

A

you can change the value of its property, but you cannot reassign a different value to the const variable.

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

How should you decide on which type of declaration to use?

A

If you intend to not change the value of the variable, use const. However, if you need to reassign a variable, use let.

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

What is the syntax for writing a template literal?

A

use backticks instead of single or double quotes. you can use $ and curly braces for JavaScript expressions

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

What is “string interpolation”?

A

the ability to substitute part of the string for the values of variables or expressions.

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

What is destructuring, conceptually?

A

assigns properties of an object to individual variables.

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

What is the syntax for Object destructuring?

A

const keyword, opening curly braces,comma to separate property value pairs. assignment operator and object name. If the variables have the same names as the properties of the object, you can make the code more concise by just having the property names and separate them with comma.

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

What is the syntax for Array destructuring?

A

const keyword, opening square brackets, variable names assignment operator and object name..

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

How can you tell the difference between destructuring and creating Object/Array literals?

A

desturcturing the curly braces are on the left and object name is on the right side of assignment operator. creating the curly braces are on the right and object name is on the left side of assignment operator.

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

What is the syntax for defining an arrow function?

A

const keyword, name of function, assignment operator, optional parenthesis for 2 or more parameters, arrow, and optional curly braces if return statement is present for code block. If no parameter, need to have empty parenthesis.

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

When an arrow function’s body is left without curly braces, what changes in its functionality?

A

for javascript expressions, you dont need curly braces. For mutiple-lined statements you need curly braces. you dont need a return statement for non-curly braces

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

How is the value of this determined within an arrow function?

A

an arrow function captures the this value of the enclosing context instead of creating its own this context. Based on surrounding scope, this was defined in.

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

What is a CLI?

A

Command Line Interface. Tool that developers use not end users.

17
Q

What is a GUI?

A

Graphical User Interface. Usually aimed at consumers of technology (end users), not producers of technology (developers). ex. VS Code.

18
Q

man

A

on-line reference manuals. brings manual for each commands.

19
Q

What are the three virtues of a great programmer?

A

laziness, impatience, hubris

20
Q

cat

A

concatenate files and print on the standard output. Allows you to open text files and see contents inside. allows you to concatenate multiple text files to display it as one.

21
Q

ls

A

list the contents of your current working directory.

22
Q

pwd

A

print name of current/working directory. shows absolute file path to the directory.

23
Q

echo

A

display a line of text. console log for the terminal

24
Q

touch

A

change file timestamps. used for automated processes. create a file if it doesn’t exist.

25
Q

mkdir

A

make directories.

26
Q

mv

A

move (rename) files.

27
Q

rm

A

remove files or directories.

28
Q

cp

A

copy files and directories.