Quiz 1 Flashcards

1
Q

temporal dead zone

A

When you try to access a variable before it has been declared/the “area”/time between the start of a scope and when a variable is actually declared

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

What is an object?

A

An object is a container of properties

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

What are properties and what can they contain?

A

Properties belong to objects and have names/“key” and values. They can take any values including other objects and functions

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

What is a prototype?

A

Inherited properties from another object is called a prototype

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

What is the highest level of a prototype

A

Object.prototype

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

What is the prototype of “hello” and the prototype of that prototype?

A
  1. String.prototype 2. Object.prototype
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

A property is found by first looking if the object itself contains the property then that object’s prototype and so on until……

A

it reached an object will null as the prototype such as Object.prototype

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

Give an example of two methods that Object.prototype contains

A

toString and hasOwnProperty

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

Give an example of two object that Object.prototype contains

A

String.prototype and Array.prototype

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

Object.create

A

Object.create(otherObject)

Used to create objects with a specified prototype

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

What does using this.object do when using a constructor?

A

Creates a property name and value for every new object instantiated with the constructor

i.e.

this.names = [‘jane’, ‘mary’]
c = new Name
d = new Name

c.names will = jane
d.names will = mary

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

hasOwnProperty vs this.object

A

hasOwnProperty can set properties by inheriting, and this.object creates new/original properties

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

Asynchronous programming allows…?

A

Allows multiple things to run at the same time. Allows part of code to start now, and finish later

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

What is a callback function?

A

A function that’s passed into another function, that when called will be called with the result

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

What is a higher order function?

A

A function that takes a function(s) as a parameter, or that returns a function

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

Give a few examples of builtin higher order functions

A

foreach, map, reduce, filter

17
Q

Why do we use/make higher order functions?

A

When we would have to do a bunch of extra things that deal with unimportant details. If we want to repeat the implementation/basic idea of a function on different parameters

18
Q

How are classes defined

A

class Name {
constructor(){}
methodOne(){}
}

19
Q

What is Object.prototype’s prototype

A

null

20
Q

Objects can be given prototypes in 3 ways:

A

Object.create, constructor functions, (ES6) classes

21
Q

Define constructor and instance. Write an example block of code

A

Constructor is a function with the “new” keyword, and creates an object/instances with the defined prototypes.

Instance is an object created by using the “new” keyword and constructors. You can also say instances are the children of constructors.

function ConstructorName(attr){
this.attr = attr
}

const newInstance = new ConstructorName(‘unique_attr’)