Javascript Flashcards

1
Q

What is the purpose of variables?

A

to use later

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

How do you declare a variable

A

var

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

var name = value

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

What character are allowed in a variable name?

A

letter, $, underscore _, number but not 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

different variables if casing is different

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

arguments

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

numerical value

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

true/false, data type

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

How do you update the value of a variable?

A

var name = value, no need to add var in front of var name

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

What is the difference between null and undefined?

A

null needs to be purposefully assigned made to be empty to be filled later

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

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

A

easier to debug later

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

Give five examples of Javascript primitives?

A

string, number, boolean, null, undefined

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

Give five examples of Javascript primitives?

A

string, number, boolean, null, undefined

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

numerical

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

What is string concatenation?

A

tie two strings together

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

What purpose(s) does the + plus operator server in JavaScript

A

concatenation, add +

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

What data type if 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 does the += “plus-equals” operator do?

A

addition assignment, take result as new value

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

What are objects used for?

A

grouping multiple properties with values that are related to each other

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

What are objects properties?

A

variables glued to objects

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

Describe object literal notation.

A

arraysof properties to their values

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

delete object.property

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

property.nameOfvalue, or property[‘nameOfvalue’], and delete property.nameOfvalue

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

What are arrays used for?

A

lists of the same purpose/context rather than related

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Describe array literal notation.
square brackets separated in commas
26
How are arrays different from "plain" objects?
arrays have number indexes, objects have key/named values/properties (arrays also have an order, objects and their properties do not)
27
What number represents the first index of an array?
0
28
What is the length property of an array?
.length, first to last # of the list/array (or total count)
29
How do you calculate the last index of an array?
using length property (.length) -1 , because indexes start at 0 , length count starts at 1
30
Describe the parts of a function definition.
function function name , return
31
Describe the parts of a function call.
function name ()
32
When comparing them side-by-side, what are the differences between a function call and a function definition?
functions definition contain the action, function calls are invoking the function to be used
33
What is the difference between a parameter and an argument?
parameters are present function definitions, arguments are present during function calls
34
Why do we log things to the console?
debugging
35
what is a method?
a way to do things
36
What is the purpose of an if statement?
gives a requirement in order to achieve the result
37
Is else required in order to use an if statement?
no
38
What is the purpose of a loop?
repeatedly run a block of code until a defined condition is met
39
What is the purpose of a condition expression in a loop?
When to continue, and when to end
40
What does "interation" mean in the context of loops?
in the beginning, once
41
Besides a return statement, which exits entire function block, which keyword exits a loop before its condition expression evaluates to false?
break statement
42
What does ++ increment operator do?
adds one (push 1)
43
How do you interate through the keys of an object?
for...in loops
44
What event is fired when a user places their cursor in a form control?
focus
45
What event is fired when a user's cursor leaves a form control?
blur
46
What event is fired as a user changes the value of the form control?
input
47
What event is fired when a user clicks the "submit" button within a ?
submit
48
What does the event.preventDEfault() method do?
non cancellable event
49
What does submitting a form without event.preventDefault() do?
prevent the browser from automatically reloading the page with the form's values in the URL.
50
What property of a form element object contains all of the form's controls?
elements property
51
What property of a form element object contains all of the form's controls?
name
52
What property of a form a control object gets and sets its value?
value
53
How to you store data in localstorage?
setItem
54
How do you retrieve data from localStorage?
getItem
55
What data type can localStorage save in the browser?
strings
56
When does the 'beforeunload' event fire on the window object?
right before you exit/refresh the page
57
What is a method?
method is a function being assigned to an object
58
How can you tell the difference between a method definition and a method call?
method is being paired to an object, function call is separate
59
Describe method definition syntax (structure).
Block of code being passed through a function with a parameter, assigned to a method name
60
Describe method call syntax (structure).
object.methodname
61
How is a method different from any other function?
Associated with an object, other function is independent
62
What is the defining characteristic of Object-Oriented programming?
data paired with methods
63
What are the four "principles" of Object-Oriented Programming?
Encapsulation, Data Abstraction, Polymorphism and Inheritance
64
What is "abstraction"?
process of hiding the implementation details and displaying only the functionality
65
What does API stand for?
Application Programming Interface
66
What is the purpose of an API?
tools available to a program
67
What is "this" in Javascript?
key word of the object you're currently working with
68
What does it mean to say that "this" is an "implicit parameter"?
no paramter in a function, "this" is being used instead
69
When is the value of "this" determined in a function; call time or definition time?
only has the value when the function is being called
70
``` 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); } }; ```
none, no function being called
71
Given the above character object, what is the result of the following code snippet? Why? character.greet();
calling on the function assigned to the property green of the character object.
72
``` Given the above character object, what is the result of the following code snippet? Why? var hello = character.greet; hello(); ```
it's a me undefined, because no function in greet
73
How can you tell what the value of this will be for a particular function or method definition?
can't know a definition
74
How can you tell what the value of this is for a particular function or method call?
object left of the dot, the window
75
What kind of inheritance does the JavaScript programming language use?
prototype
76
What is prototype in Javascript?
what objects can build off of
77
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?
grab prototypes
78
If an object does not have its own property or method by a given key, where does Javascript look for it?
on the prototypes
79
What does the 'new' operator do?
lets us create objects with a function
80
What property of JavaScript functions can store shared behavior for instances created with 'new'?
prototype
81
What does the instanceof operator do?
checks if x is in y
82
What is AJAX?
seeking out data to develop more content once a page already loaded
83
What does the AJAX acroynm stand for?
A synchronous J avaScript A nd X ML
84
Which object is built into the browser for making HTTP requests in Javascript?
XMLHttpRequest
85
What event is fired by XMLHttpRequest objects when they are finished loading the data from the server?
load
86
An XMLHttpRequest object has an addEventListener() method just like DOM elements. How is it possible that they both share this functionality?
both share a prototype
87
How is method different from any other function?
methods are attached to objects
88
How do you remove the last element from an array?
.pop()
89
How do you round a number down to the nearest integer?
Math.floor()
90
How do you generate a random number?
Math.random()
91
How do you delete an element from an array?
.splice()
92
How do you append an element to an array?
.push()
93
How do you break a string up into an array?
.split()
94
Do string methods change the original string? How would you check if you weren't sure?
no, check through console.log
95
Roughly how many string methods are there according to MDN Web Docs?
~30 (not really important, just know it's a lot)
96
Is the return value of a function or method useful in every situation?
no
97
Roughly how many array methods are there according to the MDN Web docs?
~35 (not really important, just know it's a lot)
98
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN
99
Give 6 examples of comparison operators.
< , > , !== , ===, <=, >=
100
What data type do comparison expressions evaluate to?
boolean
101
What is the purpose of an if statement?
to make a condition, should do or not
102
is else required to used an if statement?
no
103
What are the three logical operators?
&& , ||, ! (not)
104
How do you compare two different expressions in the same condition?
in the if statement, you have two expressions with logical operators separating them within the condition
105
What is the purpose of a loop?
To traverse through and have a repeated action until you're done
106
What is the purpose of a condition expression in a loop?
to check if we should still keep running the loop
107
What does "iteration" mean in the context of loops?
passing through a loop once
108
When does the condition expression of a while loop get evaluated?
When it's still true, before the code block executes
109
When does the initialization expression of a for loop get evaluated?
in the beginning only once
110
When does the condition expression of a for loop get evaluated?
second after the initialization, then after the incrementing until condition is no longer true
111
When does the condition expression of a for loop get evaluated?
after the condition until loop is no longer needed
112
What does the ++ increment operator do?
increment by 1