JavaScript Flashcards

1
Q

What is the event.target?

A

where the event originated from

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

What is the affect of setting an element to display: none?

A

removed from the document flow

hides element

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

What does the element.matches() method take as an argument and what does it return?

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

How can you retrieve the value of an element’s attribute?

A

.getAttribute

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

At what steps of the solution would it be helpful to log things to the console?

A

every step

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

If you were to add another tab and view to your HTML, but you didn’t use event delegation, how would your JavaScript code be written instead?

A

create separate event listeners for every tab

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

If you didn’t use a loop to conditionally show or hide the views in the page, how would your JavaScript code be written instead?

A

create conditional block for each view

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

What is JSON?

A

text based data format for representing data based on JavaScript object syntax

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

What are serialization and deserialization?

A

process of converting an object into a stream of bytes to more easily save or transmit

constructing a data structure or object from a series of bytes

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

Why are serialization and deserialization useful?

A

makes it easier to save or transmit data

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

How do you serialize a data structure into a JSON string using JavaScript?

A

JSON.stringify() method

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

How do you deserialize a JSON string into a data structure using JavaScript?

A

JSON.parse() method

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

How do you store data in localStorage?

A

.setItem() method
(key name, value)

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

How do you retrieve data from localStorage?

A

.getItem() method
(key/property name)

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

What data type can localStorage save in the browser?

A

string data type

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

When does the ‘beforeunload’ event fire on the window object?

A

when user refreshes or exit window

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

How can you tell the difference between a method definition and a method call?

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

Describe method definition syntax (structure).

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

Describe method call syntax (structure).

A
20
Q

How is a method different from any other function?

A
21
Q

What is the defining characteristic of Object-Oriented Programming?

A

objects can contain both data(as properties) and behavior(as methods)

22
Q

What are the four “principles” of Object-Oriented Programming?

A

abstraction, encapsulation, inheritance, polymorphism

23
Q

What is “abstraction”?

A

being able to work complex things in simple ways

24
Q

What does API stand for?

A

application programming interface

25
Q

What is the purpose of an API?

A

to enable applications to exchange data and functionality easily and securely

26
Q

What is this in JavaScript?

A

refers to an object that is executing the current piece of code

27
Q

What does it mean to say that this is an “implicit parameter”?

A

it is available in a function’s code block even though it was never declared with a variable or included in the function’s parameter list

28
Q

When is the value of this determined in a function; call time or definition time?

A

call time

29
Q

What does this refer to in the following code snippet?
var character = {
firstName: ‘Mario’,
greet: function () {
var message = ‘It's-a-me, ‘ + this.firstName + ‘!’;
console.log(message);
}
};

A

character object

30
Q

Given the above character object, what is the result of the following code snippet? Why?
character.greet();

A

It’s-a-me, Mario!

theres an object to the left of the function(method) being called

31
Q

Given the above character object, what is the result of the following code snippet? Why?
var hello = character.greet;
hello();

A

It’s-a-me, undefined!

no object before function call

32
Q

How can you tell what the value of this will be for a particular function or method definition?

A

you can’t, no way to know, waiting to be used

33
Q

How can you tell what the value of this is for a particular function or method call?

A

object before the function(method) being called

34
Q

What kind of inheritance does the JavaScript programming language use?

A

prototype-based (prototypal)

JavaScript objects give certain behaviors (methods) or data (properties) to other objects.

35
Q

What is a prototype in JavaScript?

A

an object with shared behavior or data that can be stored in one place and shared with all created instances

the procedure in which JavaScript objects inherit features from one another

36
Q

How is it possible to call methods on strings, arrays, and numbers even though those methods don’t actually exist on strings, arrays, and numbers?

A

“borrow” methods from prototype object

37
Q

If an object does not have it’s own property or method by a given key, where does JavaScript look for it?

A

each prototype object

38
Q

What does the new operator do?

A

lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function.

  1. created a blank, plain JavaScript object
  2. takes the value of the prototype property off the function being run with the new operator and make it a property of the new object
  3. makes new object this
  4. if nothing was returned(normally nothing is returned), the object created gets returned
39
Q

What property of JavaScript functions can store shared behavior for instances created with new?

A

prototype

40
Q

What does the instanceof operator do?

A

tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object, return value is a boolean

(object instanceof constructor)

41
Q

What is a “callback” function?

A

function passed into another function as an argument

42
Q

Besides adding an event listener callback function to an element or the document, what is one way to delay the execution of a JavaScript function until some point in the future?

A

setTimeout()

43
Q

How can you set up a function to be called repeatedly without using a loop?

A

setInterval

44
Q

What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?

A

0

45
Q

What do setTimeout() and setInterval() return?

A

positive integer value which identifies the timer created