javascript Flashcards

1
Q

What is the purpose of variables?

A

The purpose of variables is to store data

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

=

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 numbers dollarsign and number not at beggining

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

variables with different cases are different variables

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

The purpose of a string is to store text data

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

The purpose of a number is to store numbers, and perform math.

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

The purpose of a boolean is to denote if something is 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

the equals operator assigns a value to a variable

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

You update the value of a variable by using the = sign

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 assigned on purpose, undefined is not assigned on purpose

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

What is string concatenation?

A

The operation of combining strings into one single string

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

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
14
Q

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

A

It adds a value to a variable. It acts as a shorthand for var = var + value

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

What are objects used for?

A

For storing different but related pieces of data, and functions to perform operation on related data.

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

What are object properties?

A

Object properties are variables belonging to an object

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

Describe object literal notation.

A

Object literal notation is a way of defining an object in javascript.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
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
19
Q

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

A

bracket notation and dot notation

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

What are arrays used for?

A

Arrays are used for storing data in an indexed format

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

Describe array literal notation

A

Array literal notation is a way to describe arrays in your code

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

How are arrays different from “plain” objects”

A

Arrays are indexed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
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
24
Q

What is the length property of an array?

A

it gives the number of values in the array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
How do you calculate the last index of an array
you take the length property and subtract it by one.
26
What is a function in JavaScript?
A function is a block of code that can be run, and have values passed in, and out.
27
Describe the parts of a function definition.
The function name, the function code block, the function return, the function parameters.
28
Describe parts of a function call.
the function name, the function arguments.
29
When comparing them side-by-side, what are the differences between a function call and a function definition?
The function definition has a code block and can have a return statement, the function call has parameter values for arguments.
30
What is the difference between a parameter and an argument?
A parameter describes content that will be passed at some point into a function, an argument is a value being passed into a method we are calling.
31
Why are function parameters useful?
They help us pass data into functions so that they can be self contained (scope)
32
What two effects does a return statement have on the behavior of a function?
It returns a value, and stops code execution of the function code block.
33
Why do we log things to the console?
To debug our code
34
What is a method?
a method is a function belonging to an object
35
How is a method different from any other function?
a method is different because it is called from a function using dot notation
36
How do you remove the last element from an array?
array.pop
37
How do you round a number down to the nearest integer?
Math.floor()
38
How do you generate a random number?
Math.random()
39
How do you delete an element from an array?
array.splice()
40
How do you append an element to an array?
array.push()
41
How do you break a string up into an array?
string.split();
42
Do string methods change the original string? How would you check if you weren't sure?
String methods do not change the original string because strings are immutable. You would check using the console.
43
Roughly how many string methods are there according to the MDN Web docs?
3
44
Is the return value of a function or method useful in every situation?
No
45
Roughly how many array methods are there according to the MDN Web docs?
30
46
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN
47
Give 6 examples of comparison operators.
< > <= >= <== >== == === | | &&
48
What data type do comparison expressions evaluate to?
boolean
49
What is the purpose of an if statement?
Do introduce logic into code
50
Is else required in order to use an if statement?
no
51
Describe the syntax (structure) of an if statement.
conditional code block, condition, conditional statement
52
What are the three logical operators?
if else ( else if )
53
How do you compare two different expressions in the same condition?
you chain them together using an or or an and, you can also use parentheses to group together expressions that should be evaluated first.
54
What is the purpose of a loop?
The purpose of a loop is to iterate through data, or perform an action a certain or indefinite number of times based on a conditional.
55
What is the purpose of a condition expression in a loop.
The purpose of the condition expression is to halt the operation of the condition when certain conditions are met, or to skip over the expression entirely.
56
What does "iteration" mean in the context of loops?
iteration means a repitition of the loop.
57
When does the condition express of a while loop get evaluated?
during the beginning of each iteration.
58
When does the initilization expression for a for loop get evaluated?
during the beginning of the first iteration
59
when does the condition expression of a for loop get evaluated?
during each iteration.
60
When does the final expression of a for loop get evaluated?
the beginning of each iteration before the conditional.
61
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluated to false?
break
62
What does the ++ increment operator do?
adds 1 to a variable
63
How do you iterate through the keys of an object?
Using a for each loop
64
What event is fired when a user places their cursor in a form control?
hover
65
What event is fired when a user's cursor leaves a form control?
blur
66
What event is fired as a user changes the value of a form control?
input
67
What event is fired when a user clicks the "submit" button within a ?
submit
68
What does the event.preventDefault() method do?
prevents a form from performing its default action when used.
69
What property of a form element object contains all of the form's controls.
elements
70
What property of form a control object gets and sets its value?
name.value
71
What is one risk of writing a lot of code without checking to see if it works so far?
bugs, long debug times
72
What is an advantage of having your console open when writing a JavaScript program?
you can see bugs right away.
73
What is JSON?
JSON is a way of storing JavaScript objects in strings
74
What are serialization and deserialization?
They are the process of taking data and organizing it in a way that can be better understood
75
Why are serialization and deserialization useful?
They allow us to transmit and receive data in formats that are usable.
76
How do you serialize a data structure into a JSON string using JavaScript?
JSON.stringify()
77
How do you deserialize a JSON string into a data structure using JavaScript?
JSON.parse()
78
What does the new operator do?
The new operator creates a new instance of a function and runs it.
79
What property of JavaScript functions can store shared behavior for instances created with new?
prototype
80
What does the instanceof operator do?
Checks if the prototype is an instance of a function
81
What kind of inheritance does the JavaScript programming language use?
prototypal inheretence
82
What is a prototype in JavaScript?
A prototype is an object that stores functions.
83
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?
inheretence
84
If an object does not have it's own property or method by a given key, where does JavaScript look for it?
it's protoype chain
85
What is this in JavaScript?
this refers to the current instance of the object
86
What does it mean to say that this is an "implicit parameter"?
it is included with every function
87
When is the value of this determined in a function; call time or definition time?
during run time
88
What is a method?
A method is a function belonging to an object
89
How can you tell the difference between a method definition and a method call?
A method definition has no parentheses, and has a code block
90
Describe method definition syntax (structure).
function hello(name) { }
91
Describe method call syntax (structure).
hello('humberto')
92
How is a method different from any other function?
A method is different because it belongs to an object
93
What are the four "principles" of Object-Oriented Programming?
Abstraction Inheretence Polymorphism Encapsulation
94
What is "abstraction"?
Taking something complex and making it easy to use
95
What does API stand for?
Application programming interface
96
What is the purpose of an API?
To make it easy for others to use data in your application in their programs.