JavaScript Flashcards

1
Q

What is the purpose of variables?

A

to store data that we can access 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

variable key word with variable name, 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

Assign a value after the assignment operator

var keyword name of variable = value

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, dollar sign $, or 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

the same word lowercase and uppercase would be different variable names

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

to add new content into a page
store date with text content
save a series of characters

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

stores numeric value

count, math financial stuff, measurement of some sort

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

data type two possible values
yes or no

make decisions
do or don’t do

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

assign value to 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

reassigning it without declaring it again, without the variable keyword

var unknown = null; first time only one
unknown = 4 reassigning
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 intentional -assigned as a value, do it on purpose

undefined no value hasn’t been assigned yet -nothing, empty

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 help you debug

Always put a label

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, undefined, and 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

combine two strings or more to create one new string

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

adds one value to another or concatenation

used to join the strings on either side of it

17
Q

What data type is returned by comparing two values (, ===, etc)?

18
Q

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

A

addition assignment, adds the values on both left and right operands

19
Q

What are objects used for?

A

to group together a set of variables and functions to represent something such as a person or a car

store data together, collection of stuff

20
Q

What are object properties?

A

variable within an object

21
Q

Describe object literal notation.

A

properties of the object are stored within curly braces

22
Q

How do you remove a property from an object?

A

delete object.property

23
Q

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

A

dot notation and bracket notation

24
Q

What are arrays used for?

A

it stores a list of values

25
Describe array literal notation.
the values are assigned to the array inside a pair of square brackets, and each values separated by a comma var = [ ]
26
How are arrays different from "plain" objects?
The key for the value of an array is a number. The number is the location in the array. number indexes
27
What number represents the first index of an array?
zero [0]
28
What is the length property of an array?
holds the 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?
packages of code that can be called later in the program
31
Describe the parts of a function definition.
``` the function keyword an optional name zero or more parameters a code block an optional return statement ```
32
Describe the parts of a function call.
the function name followed by the arguments replacing the parameters in ( )
33
When comparing them side-by-side, what are the differences between a function call and a function definition?
function call passes an argument function definition is a set of instructions
34
What is the difference between a parameter and an argument?
parameter-placeholder | arguments-value to fill placeholder
35
Why are function parameters useful?
pass additional info into the function
36
What two effects does a return statement have on the behavior of a function?
causes a function to produce a value prevents any more code in the functions code block from being run