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
Q

Describe array literal notation

A

variable then bracket index values end with commas brackets

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

how are arrays different from “plain” objects?

A

Arrays are listed in an order

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

what number represents the first index of an array

A

0

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

what is the length property of an array?

A

arr.length and gives the total amount of index in an array

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

how do you calculate the last index of an array?

A

Array.length - 1

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

What is a function in JavaScript?

A

A repeatable chunk of code with a specific purpose.

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

Describe the parts of a function definition

A

Function name parameter code block and function

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

Describe the parts of a function call.

A

The function name and the parentheses which is where arguments are passed through

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

When comparing them side-by side, what are the differences between a function call and a function definition?

A

definition has a code block.

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

What is the difference between a parameter and an argument?

A

parameters are placeholders for arguments that don’t ahve a known value.

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

Why are function parameters useful?

A

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.

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

What two effects does a return statement have on the behavior of a function?

A

It causes the function to produce a value we can use in our program and prevents anymore code from running

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

why do we log things to the console.

A

To test debugging and inspect if our code works

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

what is a method?

A

A function which is a property of an object.

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

How do you remove the last element from an array?

A

Pop() method

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

How do you round a number down to the nearest integer.

A

Math.floor();

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

How do you delete an element from an array?

A

splice();

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

How do you append an element to an array?

A

push();

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

How do you break a string up into an array?

A

Split() method

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

Do string methods change the original string? how would you check if you weren’t sure?

A

They do not, and console.log the original string and go to the MDN and look at the documentation of the return value.

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

Roughly how many string methods are there according to the MDN web docs?

A

A lot

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

Is the return value of a function or method useful in every situation?

A

Sometimes but not all the time

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

Roughly how many array methods are there according to the MDN web docs? a

A

A lot

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

What three-letter acronym should u always include in your Google search about a javascript method or CSS property?

A

MDN

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

give 6 examples of comparison operator

A

< > <= >= !=== ===

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

What data type do comparison expressions evaluate to?

A

booleans

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

what is the purpose of an if statement?

A

It evaluates if a condition is true then runs the code block

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

Is else required in order to use an if statement?

A

no

53
Q

describe the syntax (structure) of an if statement

A

Function keyword function name parameter code block if statement followed by condition then curly brace return keyword

54
Q

What are the three logical operators?

A

&& || ! logical and logical or logical not

55
Q

How do you compare two different expressions in the same condition?

A

logical or operator

56
Q

what is the purpose of a loop?

A

to perform repeated tasks based on a condition

57
Q

What is the purpose of a condition expression in a loop.

A

to execute the statement if the expression evaluates to true and if its false it stops the loop

58
Q

When does the initialization expression of a for loop get evaluated

A

once before the loop begins

59
Q

What does “iteration” mean in the context of loops

A

every time the counter goes up by increment in the loop

60
Q

When does the condition expression of a for loop get evaluated?

A

before each loop iteration

61
Q

When does the final expression of a for loop get evaluated?

A

After the code block runs

62
Q

Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?

A

break

63
Q

What does the ++ increment operator do?

A

adds one to its operand and returns a value

64
Q

How do you iterate through the keys of objects?

A

for in loops

65
Q

when does the condition of a while loop get evaluated.

A

before each pass through the loop

66
Q

What are the four components of “the cascade”

A

specificity, inheritance, important source order

67
Q

What does the term “source order” mean with respect to CSS?

A

The styling that is written last is the style that will show up on the html

68
Q

How is it possible for the styles of an element to be applied to its children as well without an additional css ruleset?

A

it gets the css styling from the parent element

69
Q

list three types of selectors in order of increasing specificity

A

type class and ID selectors

70
Q

why is using !important consider bad practice

A

it makes debugging more difficult by breaking the natural cascading in your stylesheets

71
Q

What event is fired when a user places their cursor in a form control?

A

focus

72
Q

What even is fired when a user’s cursor leaves a form control?

A

blur

73
Q

What event is fired as a user changes the value of a form control?

A

input

74
Q

What event is fired when a user clicks the”submit”button within a?

A

submit

75
Q

What does the event.preventDeafult() do?

A

Prevents the browser from automatically reloading with the forms values in the URL/prevents default behavior of the form

76
Q

What does submitting a form without event.preventDefault() do?

A

automatically loads the form values

77
Q

What property of a form element object contains all of the form’s controls.

A

The element

78
Q

What property of a form control object gets and sets its value?

A

the value property

79
Q

What is one risk of writing a lot of code without checking to see if it works so far?

A

You dont know if you ran into errors halfway through writing

80
Q

What is an advantage of ahaving your console open when writing a javascript program?

A

To test your code to make sure its working

81
Q

What is JSON?

A

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
Q

What are serialization and deserialization?

A

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
Q

Why are serialization and deserialization useful?

A

You can send objects over a network and it can be parsed by the receiver

84
Q

How do you serialize a data structure into a JSON string using javascript

A

JSON.stringify();

85
Q

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

A

JSON.parse()

86
Q

How do you store data in local storage?

A

setItem();

87
Q

How do you retrieve data from local Storage?

A

getItem();

88
Q

What data type can local Storage save in the browser?

A

string data

89
Q

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

A

When the document and its resources are about to be unloaded.

90
Q

What is a method?

A

A function definition which is stored in a property of an object.

91
Q

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

A

It shows all the code necessary to run that function. Curly brace, keyword function()

92
Q

Describe method definition syntax(structure)

A

Method name with an anonymous function and the opening curly brace for the method code block and code to be run.

93
Q

describe method call syntax(structure)

A

Method call has the method of the object being called with parentheses

94
Q

How is a method different from any other function?

A

Its used on objects that include other methods and general data. Methods can use all the other tools inside the object.

95
Q

What is the defining characteristic of Object-Oriented Programming?

A

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

96
Q

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

A

Abstraction, encapsulation, inheritance and polymorphism

97
Q

What is “abstraction”?

A

Being able to work with possibly complex things in simple ways.

98
Q

What does API stand for?

A

Application programming interface

99
Q

What is the purpose of an API?

A

To give programmers a way to interact with a system in a simplified, consistent fashion: aka, abstraction

100
Q

What is this JavaScript?

A

An implicit parameter that is.

101
Q

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

A

Its available in a function code block event however it was never included in the functions parameters

102
Q

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

A

Call time

103
Q

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

A

a function returning its a me mario

104
Q

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

A

You can’t cause its not defined

105
Q

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

A

If its to the left of the dot and if there is no object then its the window global object.

106
Q

WHat kind of inheritance does the javaScript programming language use?

A

prototypal inheritance

107
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

108
Q

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

A

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
Q

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

A

within the __proto__ object

110
Q

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

A

prototype property

111
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.

112
Q

What is a “callback” function?

A

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
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();

114
Q

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

A

setInterval();

115
Q

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

A

0

116
Q

What do setTimeout() and setInterval() return?

A

timeoutID

117
Q

What is a client?

A

A piece of computer hardware or software that accesses a service made by a server.

118
Q

What is a server?

A

a piece of computer hardware or software that provides functionality for other programs or devices called clients

119
Q

Which HTTP method does a browser issue to a web server when you visit a URL?

A

GET

120
Q

What three things are on the start-line of an HTTP request message?

A

An HTTP method the request target and the http version

121
Q

what three things are on the start-line of an HTTP response message?

A

protocol version status code and status text

122
Q

What are HTTP headers?

A

a case sensitive string followed by a colon and a value who’s structure depends upon the header and additional information

123
Q

Where would you go if you wanted to learn more about a specific HTTP header?

A

MDN

124
Q

is a body required for a valid HTTP request or response message?

A

No

125
Q

What is AJAX?

A

a technique for loading data into part of a page without having to refresh the entire page.

126
Q

What does the AJAX acronym stand for?

A

asynchronous javascript and XML

127
Q

Which object is built into the browser for making HTTP requests in javascript?

A

XMLHTTPrequests

128
Q

What event is fired by XMLHTTPRequest objects when they are finished loading the data from the server?

A

load event

129
Q

AnXMLHttpRequestobject has anaddEventListener()method just like DOM elements. How is it possible that they both share this functionality?
because they are both objects?

A

They share the same prototype property