ES6 JS Flashcards

1
Q

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

A

A code block is a line of code within curly braces such as after an if statement, function call/function definition css ruleset, loop conditionals

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

What does block scope mean?

A

It means that within a code block that would be the block scope. if the block scope is local then it pertains to inside the curly braces other wise global means the whole js file.

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

both are block scoped and read-only, the content is immutable where as let, if an object can change reference data.

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

Const cannot be reassigned, variable declared by let are mutable so the values can change, const needs to be initialized.

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

The array can add elements it does not change the value. however because it is const it cannot be reassigned as it is immutable

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 u do not wish to reassign values to the variable use const, within for loops use let unless it is a for..of loop then use const.

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

` ` - using back ticks,

${variable_name } - use this syntax to substitute a variable within it

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

What is “string interpolation”?

A

It is when a a template literal has substitutions and string

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

What is destructuring, conceptually?

A

Taking properties from an object or values from an array and creating 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
let person = {
firstName: DJ
}

THIS IS THE SYNTAX: let {firstName} = person;
or const{(propertyName:(name of variable u choose)} = person; both will have different
You have a keyword either let, const, or var within an object literal

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
it is a keyword let, const, or var followed by array literal and then intialized to an array.
Ex: const array = [1,2,3]
 const [num1, num2, num 3] = array;

console.log(num1) is 1;

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

Creating object/array means it is on the right side of the assignment operator

Destructuring means it is the keyword let, const, var followed by object/array literal and then whatever is being assigned to that

CREATE: const person = [ ] || { };

Destructuring: const {you} || [you] = [ ] || { };

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
It will be parameter followed by arrow then code 
let variable_name = () => some code;
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

It does not need the return key word after the arrow

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

It inherits this from the function it is in.

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

WHAT IS CLI?

A

CommandLine InterFace

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

What is GUI?

A

Graphical User Interface, The user can move and interact with it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q
Give at least one USE case for each
man
cat
ls
pwd
echo
touch
mkdir
mv
rm
cp
A

man - manual for each command line tool
cat - prints the content of file
ls - looks at the directories list
pwd -Prints the working directory can create files within the pwd
echo - can put whats printed on CLI in a file
touch - gives a time stamp
mkdir - can make a new directory or more than one
mv - used to change a file name or move file
rm - can delete files
cp - copy the contents of one file into another one

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

what is Node.js

A

It lets javascript run outside of the browser

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

What can Node.js be used for?

A

It can be used to run javascript within the terminal, command line tools

21
Q

What is a REPL?

A

read-eval-print loop gives programmers interactive programming envrionment

22
Q

When was Node.js created?

A

2009

23
Q

What back end languages have you heard of?

A

Python, Ruby, SQL

24
Q

What is a computer process?

A

It is the process of threads that the computer runs

25
Q

Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?

A

over 500

26
Q

Why should a full stack Web developer know that computer processes exist?

A

So that they can understand memory space and such

27
Q

What is the process object in a Node.js program?

A

The process object is a global that provides information about, and control over, the current Node.js process. As a global, it is always available to Node.js applications without using require(). It can also be explicitly accessed using require():

28
Q

How do you access the process object in a Node.js program?

A

Can access by console logging or using the process object in a js file.

29
Q

What is the data type of process.argv in Node.js?

A

it is an array data type

30
Q

What is a JavaScript module?

A

it is a file with some type of functionality that will other modules creates a cohesive functional app

31
Q

What values are passed into a Node.js module’s local scope?

A

exports require module __filename, __dirname

32
Q

Give two examples of truly global variables in a Node.js program.

A

Console and process

33
Q

What is Array.prototype.filter useful for?

A

It is useful for getting indexes using a specific criteria

34
Q

What is Array.prototype.map useful for?

A

It is useful for changing all indexes of an array without having to use a for loop

data transformation - the same legnth

35
Q

what is array.prototype.reduce useful for?

A

It is useful for having a single output from an array.

36
Q

What is “syntactic sugar”?

A

It is when making code easier to read or to express while keeping functionality

37
Q

What is the typeof an ES6 class?

A

It is an function

38
Q

Describe ES6 class syntax.

A

Syntax as follows:

class (constructor Name) {

  constructor (parameter) {
        this.parameter = parameter
    }
    getP() {
          return this.parameter
      } 
}
39
Q

what is refactoring?

A

it is cleaning up the readability of code to be more concise without the functionality being changed, improves performance.

40
Q

What is a webpack?

A

It is script files concatenated into one big file

41
Q

How do you add a devDependency to a package?

A

when using npm install –save-dev (script name)

42
Q

What is an NPM script?

A

a code or file that will run continuously, or calling the script will run the file

43
Q

How do you execute Webpack with npm run?

A

use npm run and then the script name or build

44
Q

How are ES Modules different from CommonJS modules?

A

They use different syntaxes as ES6 modules use imports and exports statements where as commonJs uses module.exports and requireJS

45
Q

What kind of modules can Webpack support?

A

It supports both kind of modules

46
Q

what does fetch() return?

A

A Promise that resolves to a Response object.

47
Q

What is the default request method used by fetch()?

A

GET

48
Q

How do you specify the request method (GET, POST, etc.) when calling fetch

A
fetch (url, { method: 'POST' 
body: ,
headers: 
});
.then(response => response.json());