Javascript Flashcards

1
Q

What is the purpose of variables

A

variables hold a value of something

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

How do you declare a variable?

A

use the operator to declare a variable

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

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

A

you’d use the assignment operator

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

What characters are allowed in variable names?

A

letters dollar signs and underscore and numbers as long as it doesnt start with a number

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

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

A

If its not case sensitive then two of the same words are different values

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

what is the purpose of a string?

A

Its a series of characters in a row. Data that is not code.

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

what is the purpose of a number?

A

calculations

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

What is the purpose of a boolean

A

to represent logic values and see whether its true or false

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

What does the = operator mean in JavaScript?

A

Its the assignment operator

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

How do you update the value of a variable?

A

set the old value on the left of the assignment operator and the new value on the right

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

What is the difference between null and undefined?

A

Null is a placeholder and undefined is javaScripts way of saying empty

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

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

A

It’ll give us a point of reference

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

Give five examples of JavaScript primitives

A

Strings, booleans, undefined, numbers, and null.

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

What data type is returned by an arithmetic operation?

A

A number.

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

What is string concatenation?

A

Joining two or more values together to form a new string.

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

What purpose(s) does the + operator serve in JavaScript?

A

To add numbers and to concatenate strings

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

What data type is returned by comparing two values

A

booleans

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

What does the += “plus-equals” operator do?

A

adds the value of the right operand to a variable and assigns the result to the variable

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

What are objects used for?

A

To create a model of something you would recognize in the real world. All stored together in one area

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

What are object properties?

A

They tell us about the object. Variables that live inside an object.

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

Describe object literal notation

A

The object the key value pairs inside curly braces

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

How do you remove a property from an object.

A

The delete operator

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

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

A

Dot notation and bracket notation

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

What are arrays used for

A

it stores a list of values/groups of similar data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Describe array literal notation
variable then bracket index values end with commas brackets
26
how are arrays different from "plain" objects?
Arrays are listed in an order
27
what number represents the first index of an array
0
28
what is the length property of an array?
arr.length and gives the total amount of index in an array
29
how do you calculate the last index of an array?
Array.length - 1
30
What is a function in JavaScript?
A repeatable chunk of code with a specific purpose.
31
Describe the parts of a function definition
Function name parameter code block and function
32
Describe the parts of a function call.
The function name and the parentheses which is where arguments are passed through
33
When comparing them side-by side, what are the differences between a function call and a function definition?
definition has a code block.
34
What is the difference between a parameter and an argument?
parameters are placeholders for arguments that don't ahve a known value.
35
Why are function parameters useful?
They are placeholder for arguments. If there were not parameters the behavior would always be the same. It gives us the ability to allow our behavior to act based on a certain set of values.
36
What two effects does a return statement have on the behavior of a function?
It causes the function to produce a value we can use in our program and prevents anymore code from running
37
why do we log things to the console.
To test debugging and inspect if our code works
38
what is a method?
A function which is a property of an object.
39
How do you remove the last element from an array?
Pop() method
40
How do you round a number down to the nearest integer.
Math.floor();
41
How do you delete an element from an array?
splice();
42
How do you append an element to an array?
push();
43
How do you break a string up into an array?
Split() method
44
Do string methods change the original string? how would you check if you weren't sure?
They do not, and console.log the original string and go to the MDN and look at the documentation of the return value.
45
Roughly how many string methods are there according to the MDN web docs?
A lot
46
Is the return value of a function or method useful in every situation?
Sometimes but not all the time
47
Roughly how many array methods are there according to the MDN web docs? a
A lot
48
What three-letter acronym should u always include in your Google search about a javascript method or CSS property?
MDN
49
give 6 examples of comparison operator
< > <= >= !=== ===
50
What data type do comparison expressions evaluate to?
booleans
51
what is the purpose of an if statement?
It evaluates if a condition is true then runs the code block
52
Is else required in order to use an if statement?
no
53
describe the syntax (structure) of an if statement
Function keyword function name parameter code block if statement followed by condition then curly brace return keyword
54
What are the three logical operators?
&& || ! logical and logical or logical not
55
How do you compare two different expressions in the same condition?
logical or operator
56
what is the purpose of a loop?
to perform repeated tasks based on a condition
57
What is the purpose of a condition expression in a loop.
to execute the statement if the expression evaluates to true and if its false it stops the loop
58
When does the initialization expression of a for loop get evaluated
once before the loop begins
59
What does "iteration" mean in the context of loops
every time the counter goes up by increment in the loop
60
When does the condition expression of a for loop get evaluated?
before each loop iteration
61
When does the final expression of a for loop get evaluated?
After the code block runs
62
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
break
63
What does the ++ increment operator do?
adds one to its operand and returns a value
64
How do you iterate through the keys of objects?
for in loops
65
when does the condition of a while loop get evaluated.
before each pass through the loop
66
What are the four components of "the cascade"
specificity, inheritance, important source order
67
What does the term "source order" mean with respect to CSS?
The styling that is written last is the style that will show up on the html
68
How is it possible for the styles of an element to be applied to its children as well without an additional css ruleset?
it gets the css styling from the parent element
69
list three types of selectors in order of increasing specificity
type class and ID selectors
70
why is using !important consider bad practice
it makes debugging more difficult by breaking the natural cascading in your stylesheets
71
What event is fired when a user places their cursor in a form control?
focus
72
What even is fired when a user's cursor leaves a form control?
blur
73
What event is fired as a user changes the value of a form control?
input
74
What event is fired when a user clicks the "submit" button within a ?
submit
75
What does the event.preventDeafult() do?
Prevents the browser from automatically reloading with the forms values in the URL/prevents default behavior of the form
76
What does submitting a form without event.preventDefault() do?
automatically loads the form values
77
What property of a form element object contains all of the form's controls.
The element
78
What property of a form control object gets and sets its value?
the value property
79
What is one risk of writing a lot of code without checking to see if it works so far?
You dont know if you ran into errors halfway through writing
80
What is an advantage of ahaving your console open when writing a javascript program?
To test your code to make sure its working
81
What is JSON?
A format we can represent data in most commonly used to send data across a network. Syntax is taht of a javascript object. it stands for javascript object notation
82
What are serialization and deserialization?
Serialization is the process of turning an object in memory into a stream of bytes so you can store it or send it over a network. Deserialization is the opposite where you turn the stream of bytes into an object in memory.
83
Why are serialization and deserialization useful?
You can send objects over a network and it can be parsed by the receiver
84
How do you serialize a data structure into a JSON string using javascript
JSON.stringify();
85
How do you deserialize a JSON string into a data structure using JavaScript
JSON.parse()
86
How do you store data in local storage?
setItem();
87
How do you retrieve data from local Storage?
getItem();
88
What data type can local Storage save in the browser?
string data
89
When does the 'beforeunload' event fire on the window object?
When the document and its resources are about to be unloaded.
90
What is a method?
A function definition which is stored in a property of an object.
91
How can you tell the difference between a method definition and a method call?
It shows all the code necessary to run that function. Curly brace, keyword function()
92
Describe method definition syntax(structure)
Method name with an anonymous function and the opening curly brace for the method code block and code to be run.
93
describe method call syntax(structure)
Method call has the method of the object being called with parentheses
94
How is a method different from any other function?
Its used on objects that include other methods and general data. Methods can use all the other tools inside the object.
95
What is the defining characteristic of Object-Oriented Programming?
Objects can contain both data(as properties) and behavior (as methods)
96
What are the four "principles" of Object-Oriented Programming?
Abstraction, encapsulation, inheritance and polymorphism
97
What is "abstraction"?
Being able to work with possibly complex things in simple ways.
98
What does API stand for?
Application programming interface
99
What is the purpose of an API?
To give programmers a way to interact with a system in a simplified, consistent fashion: aka, abstraction
100
What is this JavaScript?
An implicit parameter that is.
101
What does it mean to say that this is an "implicit parameter"?
Its available in a function code block event however it was never included in the functions parameters
102
What is the value of this determined in a function; call time or definition time?
Call time
103
Given the above character object, what is the result of the following code snippet? why? character.greet();
a function returning its a me mario
104
How can you tell what the value of this will be for a particular function or method definition
You can't cause its not defined
105
How can you tell what the value of this is for a particular function or method call.
If its to the left of the dot and if there is no object then its the window global object.
106
WHat kind of inheritance does the javaScript programming language use?
prototypal inheritance
107
What is a prototype in JavaScript
a Javascript prototype is simply an object that contains properties and (predominantly) methods that can be used by other objects
108
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
Its placed in a prototype object and then the objects will delegate to that object when they aren't able to perform the required tasks themselves
109
If an object does not have its own property or method by a given key, where does Javascript look for it?
within the __proto__ object
110
What property of JavaScript functions can store shared behavior for instances created with new?
prototype property
111
What does the instanceOf operator do?
tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object.
112
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 a routine or action
113
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?
setTimeout();
114
How can you set up a function to be called repeatedly without using a loop?
setInterval();
115
What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?
0
116
What do setTimeout() and setInterval() return?
timeoutID
117
What is a client?
A piece of computer hardware or software that accesses a service made by a server.
118
What is a server?
a piece of computer hardware or software that provides functionality for other programs or devices called clients
119
Which HTTP method does a browser issue to a web server when you visit a URL?
GET
120
What three things are on the start-line of an HTTP request message?
An HTTP method the request target and the http version
121
what three things are on the start-line of an HTTP response message?
protocol version status code and status text
122
What are HTTP headers?
a case sensitive string followed by a colon and a value who's structure depends upon the header and additional information
123
Where would you go if you wanted to learn more about a specific HTTP header?
MDN
124
is a body required for a valid HTTP request or response message?
No
125
What is AJAX?
a technique for loading data into part of a page without having to refresh the entire page.
126
What does the AJAX acronym stand for?
asynchronous javascript and XML
127
Which object is built into the browser for making HTTP requests in javascript?
XMLHTTPrequests
128
What event is fired by XMLHTTPRequest objects when they are finished loading the data from the server?
load event
129
An XMLHttpRequest object has an addEventListener() method just like DOM elements. How is it possible that they both share this functionality? because they are both objects?
They share the same prototype property