Javascript Flashcards

1
Q

Javascript primitives and variables

What is the purpose of variables?

A

Store values

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

Javascript primitives and variables

How do you declare variable?

A

specify the type, leave at least one space, then the name for the variable and end the line with a semicolon ( ; ).

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

Javascript primitives and variables

How do you initialize (assign a value to) a variable?

A

const, let, var

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

Javascript primitives and variables

What characters are allowed in variable names?

A

period, underscore, $,#,@

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

Javascript primitives and variables

What does it mean to say that variable names are “case sensitive”?

A

Example

let apple
let Apple

they are different

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

Javascript primitives and variables

what is the purpose of a string?

A

It represents text

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

Javascript primitives and variables

What is the purpose of a number?

A

It represents number values

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

Javascript primitives and variables

What is the purpose of a boolean?

A

true/false statements

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

Javascript primitives and variables

What does the = operator mean in Javascript?

A

Compare values and calculation?

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

Javascript primitives and variables

How do you update the value of a variable?

A
var totalPets = 10000;
totalPets  =  23;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Javascript primitives and variables

What is the difference between null and undefined?

A

Null: intentional absence of the value
Undefined: The value doesn’t exist

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

Javascript primitives and variables

Why is it a good habit to include “labels” when you log values to the browser console?

A

Debugging, or know where you are at

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

Javascript primitives and variables

Give five examples of JavaScript primitives.

A

string, number, undefined, null, boolean

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

Javascript operators and expressions

What data type is returned by an arithmetic operation?

A

number

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

Javascript operators and expressions

What is string concatenation?

A

Adding strings with + operator

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

Javascript operators and expressions

What purpose(s) does the + plus operators serve in Javascript

A

Concatenation

arithmetic

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

Javascript operators and expressions

What data type is returned by comparing two values (, ===, etc?)

A

boolean

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

What are objects used for?

A

To shape a model, multiple types of data, or functions

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

What are object properties?

A

variables that are attached to the object

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

Describe object literal notation

A

{ key: value}

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

How do you remove a property from an object?

A

Delete operator

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

What are the two ways to get or update the value of a property?

A

Dot or bracket notation

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

What are arrays used for?

A

Store the data?

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

What are arrays used for?

A

Store the data?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Describe array literal notation
var name = [];
26
How are arrays different from "plain" objects?
single variables
27
What number represents the first index of an array?
0
28
What is the length property of an array?
number of items in an array
29
How do you calculate the last index of an array?
arr.length -1
30
function defined name convertMinutesToseconds with one parameter (minutes) and then opening curlybrace for the code block expression 60 *minutes being assgined to variable seconds return of the function value is being assigned to
31
What is a function in JavaScript?
32
Describe the parts of function definition.
33
Describe the parts of a function call?
34
When comparing them side-by-side, what are the difference between a fucntion call and a function
35
What is the difference between a parameter and argument?
parameter: placehodler arguments: giving values
36
Why are function parameters useful?
Takes arguments to the function
37
Why do we log things to the console?
Check if it's working
38
What is a method?
function that is property of the object
39
How is a method different from any other function?
Connected to any other object
40
How do you remove the last element from an array?
.pop
41
Round number down?
.floor
42
How do you generate a random number?
Math.random * array.length
43
How do you delete an element from an array?
splice
44
How do you append an element to an array?
push
45
How do you break a string up into an array?
.split space, comma,
46
Do string methods change the original string? | How would you check if you weren't sure?
Strings are unchangeable | console log the original string value and console lot the
47
Roughly how many string methods are there according to the MDN Web docs?
Around 50ish.
48
Is the return value of a function or method useful in every situation?
No, console.log , they aren't needed.
49
Roughly how many array methods are there according to the MDN Web docs?
A lot aournd 50ish
50
What three-letter acronym should you slways include in your Google search about a Javascript method or CSS property?
MDN
51
Give 6 examples of comparison operators
=, ==, ===, <=, >=, !=
52
What data type do comparison expressions evaluate to?
Boolean
53
What is the purpose of an if statement?
to give conditions to the function | run different code depending on the boolean value
54
Is else required in order to use an if statement?
Not necessarily else is needed if the condition is false else if is needed to specify a new condition to test, if the first condition is false
55
Describe the syntax ( structure) of an if statement?
if (condition) {
56
What are the three logical operators?
|| && !
57
How do you compare two different expressions in the same condition?
Using parenthesis
58
what is the purpose of loop?
check condition to run the code block
59
What is the purpose of a condition expression in a loop?
it keeps the loop going until the certain point
60
what does "iteration? mean in the context of loops?
repeating process
61
When does the condition expression of a while loop get evaluated?
before the
62
When does the initialization expression of a for loop get evaluated?
as it begins, just once
63
When does the condition expression of a for loop get evaluated?
before each iteration
64
When does the final expression of a for loop get evaluated?
before the evaluation of next condition
65
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
Use a break statement to exit the loop before the condition expression evaluates to false.
66
What does the ++ increment operator do?
(adds one to) its operand and returns a value.
67
How do you iterate through the keys of an object?
for (var key in object) for ... in loop
68
What event is fired when a user places their cursor in a form control?
focus?
69
What event is fired when a user's cursor leaves a form control?
blur
70
What event is fired as a user changes the value of a form control?
input
71
What event is fired when a user clicks the "submit" button within a ?
submit event?
72
What does the event.preventDefault() method do?
resetting, default behavior of that function.
73
What does submitting a form without event.preventDefault() do?
automatically reloads the page
74
What property of a form element object contains all of the form's controls.
,elements
75
What property of a form control object gets and sets its value?
value property
76
What is one risk of writing a lot of code without checking to see if it works so far?
error is wrong and don't know hwere
77
What is an advantage of having your console open when writing a JavaScript program?
To see step by step, what's going on.
78
What is JSON?
its a form where they keep data
79
What are serialization and deserialization?
a process of converting an Object into stream of bytes so that it can be transferred over a network or stored in a persistent storage. Deserialization:process of decoding the data that is in JSON format into native data type
80
How do you serialize a data structure into a JSON string using JavaScript?
JSON.stringify or manually create the JSON string format
81
How do you deserialize a JSON string into a data structure using JavaScript?
JSON.parse
82
What is a method?
function that is a property of an object.
83
How can you tell the difference between a method definition and a method call?
method definition needs to be related with object? method call is to when we tell javascript to run the code in the function
84
Describe method definition syntax (structure).
Function operator.name, parameter, opening curly brace,
85
Describe method call syntax (structure).
object.
86
How is a method different from any other function?
It needs to be in an object
87
What is the defining characteristic of Object-Oriented Programming?
objects can contain both data (as properties) and behavior (as methods).
88
What are the four "principles" of Object-Oriented Programming?
Abstraction Encapsulation Inheritance Polymorphism
89
What is "abstraction"?
being able to work with (possibly) complex things in simple ways. DOM
90
What does API stand for?
application programming interface
91
What is the purpose of an API?
Pass application to each other
92
What is this in JavaScript?
Generally an object, reference electrical scope of when the function is called
93
What does it mean to say that this is an "implicit parameter"?
It does not need to be explicitly defined.
94
When is the value of this determined in a function; call time or definition time?
call time
95
What does this refer to in the following code snippet?
character object
96
Given the above character object, what is the result of the following code snippet? Why?
It's-a-me, Mario!
97
Given the above character object, what is the result of the following code snippet? Why?
It's a me, undefined
98
How can you tell what the value of this will be for a particular function or method definition?
Can't be for sure.
99
How can you tell what the value of this is for a particular function or method call?
look at the scope
100
What kind of inheritance does the JavaScript programming language use?
prototype-based inheritance | prototypical
101
What is a prototype in JavaScript?
It's an object with those methods and functions object that's inherited down to that prototype
102
How is it possible to call methods on strings, arrays, and numbers even though those methods don't actually exist on objects, arrays, and numbers?
They exist in prototype
103
If an object does not have its own property or method by a given key, where does JavaScript look for it?
The prototype chain
104
What is a client?
computer controlled device | Somebody who makes the request
105
What is a server?
a computer program or device that provides a service to another computer programs and its user handles request
106
Which HTTP method does a browser issue to a web server when you visit a URL?
HTTP request GET
107
What three things are on the start-line of an HTTP request message?
method, request URL, http version
108
What three things are on the start-line of an HTTP response message?
protocol version, status code, status text
109
What are HTTP headers?
headers are way of pssing information between client and server
110
Where would you go if you wanted to learn more about a specific HTTP Header?
Check MDN
111
Is a body required for a valid HTTP request or response message?
No, optional
112
What does the new operator do?
It creates an object (There are 4 of them) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new
113
What property of JavaScript functions can store shared behavior for instances created with new?
prototype
114
What does the instanceof operator do?
Checks if the prototype property of a constructor appears anywhere in the prototype chain of an object. Returns boolean value.
115
What is a "callback" function?
a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action. https://developer.mozilla.org/en-US/docs/Glossary/Callback_function
116
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?
global function | setInterval() or setTimeout();
117
How can you set up a function to be called repeatedly without using a loop?
setInterval()
118
What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?
0
119
What do setTimeout() and setInterval() return?
return of callback function? timeoutID or intervalID
120
What is AJAX?
Stands for Asynchronous Javascript and XML programming practice of building webpages using a technology known as XMLHttpRequest. browser API working with network to without having to load a new webpage,
121
What does the AJAX acronymm stand for?
Asynchronous Javascript and XML
122
Which object is built into the browser for making HTTP requests in JavaScript?
XMLHttpRequest var xhr = new XMLHttpRequest(); xhr.open("GET", url);
123
What event is fired by XMLHttpRequest objects when they are finished loading the data from the server?
'load'
124
Bonus Question: An XMLHttpRequest object has an addEventListener() method just like DOM elements. How is it possible that they both share this functionality?
it's the prototype chain.
125
What other events are fired on xrh?
progress, *load*, *error*, abort,
126
Bonus question | what is xml
extensible markup language, no pre-defined tag names
127
What is Array.prototype.filter useful for | higher-order function: array method? or function that calls the function. ask them for clarification
When we want to narrow down to specific result
128
What is Array.prototype.map useful for
To visit each item in an array to manipulate them
129
What is Array.prototype.reduce useful for?
to accumulate a single value from an array