JavaScript Primitives, Variables, Objects, and Arrays Flashcards

1
Q

What is the purpose of variables?

A

To store data that can be referenced later in your code

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 varName = data type

vet/let/const followed by varName followed by the assignment operator followed by the datatype

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

var varName = varValue/Data

You use the assignment operator

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

Names can contain letters, digits, underscores, and dollar signs

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

To call the value of a variable, you must type the name exactly as you did when you declared the value to the name of the variable

camelCase

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

They are used to add new content into a page and they can contain markup

It’s a way to store data we can pass around

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

A number is used mainly for calculations

These store numeric values

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

They help determine which part of the script should run

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

It is an assignment operator

It is saying you are going to assign a value to the variable

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

What is the difference between null and undefined?

A

Undefined means it has an empty value

Null is an empty value but it was put there for a reason

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

Why is it a good habit to include “labels” when you log values to the browser console?

A

It describes the variable or the value being logged

It is used for clarity - Labels help understand where and what the value is for

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

Give five examples of JavaScript primitives.

A

Undefined, null, boolean, string, number

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

What data type is returned by an arithmetic operation?

A

Arithmetic Operators are used for basic math

The data type returned would be number

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

What is string concatenation?

A

String Concatenation is where you combine strings

‘Hello’ + ‘ ‘ + ‘World’ = Hello World

Two separate strings get glued together

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

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

A

A boolean datatype is returned

True -or- False

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

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

A

Additional Assignment

This adds the value of the right operand to a variable and assigns the result to the variable