JavaScript Flashcards

1
Q

What is the purpose of variables

A

To store info 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

let or 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, $, _

can’t start with numbers

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

variables are case sensitive

A

True

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

Purpose of strings?

A

store text

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

purpose of numbers?

A

calculations or adjusting CSS

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

purpose of a boolean?

A

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?

A

assignment

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

variable name = new value

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

null vs undefined?

A

Nulls are set intentionally by the developer, whereas undefined is set by JS.
Null may indicate that a value will be assigned eventually.

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

Why is it a good habit to include “labels” when logging values.

A

Good for debugging.

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

5 examples of JS Primitives

A

String, number, Boolean, undefined, 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

number

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

What is string concatenation?

A

combining strings together into a new string

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

What purpose does the + plus operator serve in JavaScript?

A

Adds numbers together or concatenating 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 (, ===, etc.)?

A

Boolean

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

What does += do?

A

Adds a value onto a variable, and then stores that new value into the same variable.

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

Operant

A

Value that an operator is operating on

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

What are objects used for?

A

Grouping data that are related to eachother

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

What are object properties?

A

variables in an object

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

Describe object literal notation

A

Key value pairs separated by commas, stored between two curly brackets, and is assigned to a variable. Keys and values are separated with a colon.

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

How do you remove a property from an object?

A

Delete operator then use dot notation to choose the property or method

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

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

A

Dot notation or bracket

25
What are arrays used for?
Storing information that is related with each other with an order. Also used when you don't know how much space you need.
26
Describe array literal notation.
Values separated by commas within square brackets and then assigned to a variable.
27
How are arrays different from "plain" objects?
The key is an index number.
28
What number represents the first index of an array?
0
29
What is the length property of an array?
Tells you how many items is in the array.
30
How do you calculate the last index of an array?
You subtract one from the length of the array.
31
Why do we log things to the console?
debugging and verification
32
what is a method?
A function that is a property of an object.
33
How is a method different from any other function?
properties of an object | you can also work with other data part of that object
34
how do you remove the last element from an array
pop
35
how do you round a number down to the nearest integer
Math.floor()
36
how do you generate a random number?
Math.random()
37
How do you delete an element from an array?
Splice, pop, shift
38
How do you break a string up into an array
.split()
39
Do string methods change the original string?
No
40
Roughly how many strings are there according to the MDN Web docs?
~40
41
Roughly how many array methods are there according to the MDN Web docs?
~30
42
Use MDN
Use MDN
43
Give 6 examples of comparison operators.
``` === >= <= > < !== ```
44
What data type do comparison expressions evaluate to?
Boolean
45
What is the purpose of an if statement?
Decisions
46
Is else required in order to use an if statement?
No
47
Describe the syntax of an if statement
``` conditional statement (condition in parenthesis ) { code block in curly brackets } other conditionals statements if necessary ```
48
What are the three logical operators?
&&, ||, !
49
How do you compare two different expressions in the same condition?
logical operators
50
What is the purpose of a loop?
To run a set of code one or more times
51
What is the purpose of a condition expression in a loop?
Tells the loop when to run the code. | Provides a stopping point.
52
What does "iteration" mean in the context of loops?
It is every time you run through a loop code block.
53
When does the condition expression of a while loop get evaluated?
It happens before each iteration.
54
When does the initialization expression of a for loop get evaluated?
It is the first thing that happens.
55
When does the condition of a for loop get evaluated?
It gets evaluated before each iteration.
56
When does the final expression of a for loop get evaluated?
It gets evaluated after each iteration.
57
Besides return, what keyword exits a function block?
break
58
What does the ++ increment operator do?
adds one
59
how do you iterate through keys of an object?
for in loop