JavaScript Flashcards

(61 cards)

1
Q

What is the purpose of variables?

A

variables store primitives like numbers, strings and boolean

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 keyword

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

equal sign

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 and digits

Must start with a letter, $ or _

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

It means capitalized variable names and non-capitalized variable names are 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

It stores text

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

It stores 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

It stores 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

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

use assignment operator again

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

undefined has been assigned but does not have a value. Null is intentionally left blank.

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 you log values to the browser console?

A

for clarity and visibility

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

Give five examples of JavaScript primitives.

A

numbers, strings, boolean, null and 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

number

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

What is string concatenation?

A

adding 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 serve in JavaScript?

A

arithmetic and concatenation

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 the += “plus-equals” operator do?

A

addition operator

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

What are objects used for?

A

To store multiple properties in one variable name

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

What are object properties?

A

data of the object

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

Describe object literal notation.

A

starts with variable declaration followed by curly brackets with property names in them.

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

use 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 or 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

To keep lists of data and access them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Describe array literal notation.
brackets and data separated by commas
26
How are arrays different from "plain" objects?
They are in order and indexed
27
What number represents the first index of an array?
zero
28
What is the length property of an array?
it returns how many data are inside the array
29
How do you calculate the last index of an array?
subtract one from the length of the array since it starts at zero
30
What is a function in JavaScript?
Reusable code block
31
Describe the parts of a function definition.
function name, parameter, code block
32
Describe the parts of a function call.
functionName(argument)
33
When comparing them side-by-side, what are the differences between a function call and a function definition?
call is using arguments and definition is using parameters
34
Why are function parameters useful?
Because unlike constant values, we can make changes to that one parameter and rest of the code block will change
35
What two effects does a return statement have on the behavior of a function?
It returns a value and executes the function
36
Why do we log things to the console?
To debug and for data accuracy
37
What is a method?
Method is a function that is a property of an object
38
How is a method different from any other function?
It is exclusive to the object
39
How do you remove the last element from an array?
pop() method of array object
40
How do you round a number down to the nearest integer?
floor) method of Math object
41
How do you generate a random number?
random() method of Math object
42
How do you delete an element from an array?
Either shift() or splice() method of array object
43
How do you append an element to an array?
push() method of array object
44
How do you break a string up into an array?
split() method of string object
45
Do string methods change the original string? How would you check if you weren't sure?
No it does not. Use console log to check.
46
Roughly how many string methods are there according to the MDN Web docs?
A lot. Maybe like 20 to 30.
47
Is the return value of a function or method useful in every situation?
No
48
Roughly how many array methods are there according to the MDN Web docs?
A lot. Maybe like 20 to 30.
49
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN
50
What is the purpose of an if statement?
Decision making
51
What are the three logical operators?
And, Or, Not
52
What is the purpose of a loop?
To repeat our desired action
53
What is the purpose of a condition expression in a loop?
To eventually stop the loop from running forever
54
What does "iteration" mean in the context of loops?
To repeat things easily
55
When does the condition expression of a while loop get evaluated?
Before each repetition starts
56
When does the initialization expression of a for loop get evaluated?
At the beginning of for loop (only once)
57
When does the condition expression of a for loop get evaluated?
Before each repetition starts
58
When does the final expression of a for loop get evaluated?
At the end of each repetition
59
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
break statement
60
What does the ++ increment operator do?
Increments by 1 and updates
61
How do you iterate through the keys of an object?
use for in loop (var in object)