JAVASCRIPT Flashcards

1
Q

What is the purpose of variables?

A

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 let const

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

number, letter, underscore, $

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

lowercase and uppercase matters

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

store letters

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

store numerical data

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 used to make decisions

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

assign

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

reassign a new value

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: no value assigned
null: set to nothing

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

to know what you are actually logging

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

Give five examples of JavaScript primitives.

A

number, string, 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

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

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

addition of numbers and concatenation of 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 the += “plus-equals” operator do?

A

assigns the value of the variable to the previous value plus right-side of operator

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

What are objects used for?

A

store multiple types of data that are related

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

What are object 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

{key: value}

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

object.property (dot notation)

object[‘property’] (square 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

store data in order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Describe array literal notation.
var array = [ ]
26
How are arrays different from "plain" objects?
numeric indexes vs named properties | arrays have order
27
What number represents the first index of an array?
0
28
What is the length property of an array?
number of items in the array
29
How do you calculate the last index of an array?
[array.length-1]
30
What is a function in JavaScript?
a set of statements that performs a task or calculates a value
31
Describe the parts of a function definition.
1. function keyword 2. optional name 3. zero or more parameters in ( ) separated by commas 4. code block { } 5. optional return statement inside code block
32
Describe the parts of a function call.
1. functions name | 2. zero or more arguments in ( ) separated by commas
33
When comparing them side-by-side, what are the differences between a function call and a function definition?
function calls do not have code blocks or keyword
34
What is the difference between a parameter and an argument?
parameters are placeholders in a function definition | arguments are actual data in a function call
35
Why are function parameters useful?
reusability and variability
36
What two effects does a return statement have on the behavior of a function?
causes the function to produce a value | also exits the function; no code after the return statement is executed
37
Why do we log things to the console?
so we can keep track of our data as we change it
38
What is a method?
a function
39
How is a method different from any other function?
function which is a property of an object, static and instance
40
How do you remove the last element from an array?
array.pop( )
41
How do you round a number down to the nearest integer?
Math.floor( )
42
How do you generate a random number?
Math.random( )
43
How do you delete an element from an array?
array. pop( ) end array. shift( ) start array. splice( ) anywhere
44
How do you append an element to an array?
array. push( ) end | array. unshift( ) start
45
How do you break a string up into an array?
string.split( )
46
Do string methods change the original string? How would you check if you weren't sure?
no. log to console before and after method
47
Is the return value of a function or method useful in every situation?
no
48
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN
49
Give 6 examples of comparison operators.
, <=, >=, ==, ===
50
What data type do comparison expressions evaluate to?
boolean
51
What is the purpose of an if statement?
to make decisions
52
Is else required in order to use an if statement?
no
53
Describe the syntax (structure) of an if statement.
if (condition) {codeblock}
54
What are the three logical operators?
&&AND ||OR !NOT
55
How do you compare two different expressions in the same condition?
$$ ||
56
What is the purpose of a loop?
to repeat the same, or similar, code a number of times
57
What is the purpose of a condition expression in a loop?
to stop the loop
58
What does "iteration" mean in the context of loops?
each time the loop runs
59
When does the condition expression of a loop get evaluated?
before each iteration
60
When does the initialization expression of a for loop get evaluated?
once, when the loop begins
61
When does the final expression of a for loop get evaluated?
after each iteration
62
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
break
63
What does the ++ increment operator do?
increments (adds one to) its operand and returns a value
64
How do you iterate through the keys of an object?
for in loop
65
In JavaScript, when is a function's scope determined; when it is called or when it is defined?
defined
66
What allows JavaScript functions to "remember" values from their surroundings?
closures