JavaScript 2 Flashcards

1
Q
  • What is JSON?
A
  • JavaScript Object Notation, A text-based data format following JavaScript object syntax, it exists as a string
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  • What are serialization and deserialization?
A
  • Converting a native object to a string is serialization while converting a a string to a native object is called deserialization
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  • Why are serialization and deserialization useful?
A
  • To transmit data across a network and to receive it from the network.
    *
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A
  • JSON.stringify();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  • How do you deserialize a JSON string into a data structure using JavaScript?
A
  • JSON.parse();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  • How to you store data inlocalStorage?
A
  • localStorage.setItem();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  • How to you retrieve data fromlocalStorage?
A
  • localStorage.getItem();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  • What data type canlocalStoragesave in the browser?
A
  • Strings
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  • When does the’beforeunload’event fire on thewindowobject?
A
  • It fires a window before everything is unloaded to cancel the event before the browser unloads all the information stored.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  • What DOM element property tells you what type of element it is?
A
  • . .tagName;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  • Describe methoddefinitionsyntax (structure).
A
  • Stored in an object a property and anonymous function definition
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  • Describe methodcallsyntax (structure)
A
  • .method();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  • What is thedefining characteristicof Object-Oriented Programming?
    .
A
  • objects can contain both data (as properties) and behavior (as methods).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  • What are the four “principles” of Object-Oriented Programming?
A
  • Abstraction, inheritance, encapsulation and polymorphism
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
  • What is “abstraction”?
A
  • Being able to work with complex things in simple ways. Like a light switch or automatic transmission.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
  • What does API stand for?
A
  • Application programming Interface.
17
Q
  • What is the purpose of an API?
A
  • To give programmers a way to interact with a system in a simplified consistent fashio
18
Q
  • What isthisin JavaScript?
A
  • This implicit parameter of every javascript function that contains
    a reference to the object is bring called from
19
Q
  • What does it mean to say thatthisis an “implicit parameter”?
A
  • Its always available we don’t need to write it
20
Q
  • Whenis the value ofthisdetermined in a function;call timeordefinition time?
A
  • Call
21
Q
  • How can you tell what the value ofthiswill be for a particular function or methoddefinition?
A
  • It won’t be anything
22
Q
  • How can you tell what the value ofthisis for a particular function or methodcall?
    .
A
  • its the object next to the method
23
Q
  • What kind of inheritance does the JavaScript programming language use?
A
  • Prototypal inheritance
24
Q
  • What is a prototype in JavaScript?
A

a JavaScript prototype is simply an object that contains properties and (predominantly) methods that can be used by other objects.

25
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
  • They inherit them from the prototype object
26
Q
  • If an object does not have it’s own property or method by a given key, where does JavaScript look for it?
A
  • Prototype
27
Q
  • What does thenewoperator do?
A
  • Creates a blank plain object and adds a property to the new object proto , it binds the new created object as the this context and return this if the function doesn’t return an object
28
Q
  • What property of JavaScript functions can store shared behavior for instances created withnew?
A
  • Proto
29
Q
  • What does theinstanceofoperator do?
A
  • Tests to see if the prototype property of a constructor appears in the prototype chain of an object, it returns a boolean
30
Q
  • What is a “callback” function?
A
  • A function definition stored as an argument
31
Q
  • Besides adding an event listener callback function to an element or thedocument, what is one way to delay the execution of a JavaScript function until some point in the future?
A
  • setTimeout()
32
Q
  • How can you set up a function to be called repeatedly without using a loop?
A
  • setInterval()
33
Q
  • What is the default time delay if you omit thedelayparameter fromsetTimeout()orsetInterval()?
A
  • 0
34
Q
  • What dosetTimeout()andsetInterval()return?
A
  • A positive integer value to identify the timer