JavaScript Foundations Flashcards

1
Q

What is the purpose of variables?

A

To store values

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

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 = ‘assignedValue’

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 after first letter: numbers, letters, _, $

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

var varName is different from var varname

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 store a value that contains any 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

Used to manipulate numbers/do math

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

Create logic in a JavaScript file. Sets up true/false values

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 used as a way to assign values to variables

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

Either declare it again or edit the value where the variable was declared earlier

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 means it is defined but intentionally missing a value

Undefined means it isn’t defined and it doesn’t exist

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 readability/communication for those reading the code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
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
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

‘string’+’string’ which combines the 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

It concatenates values

17
Q

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

A

Boolean

18
Q

What are objects used for?

A

To store data/values that are bigger than if you just stored it into one variable

19
Q

What are object properties?

A

The defining characteristics of an object

20
Q

Describe object literal notation.

A

const objectName = { property1: key1, property2: key2,… etc } ;

21
Q

How do you remove a property from an object?

A

Use the delete operator

Example:
delete objectName.property1

22
Q

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

A

Using dot notation:
objectName.propertyName or objectName.propertyName = newValue

Using bracket notation:
objectName[‘propertyName’] or objectName[‘propertyName’] = newValue

23
Q

What are arrays used for?

A

Stores a list of values

24
Q

Describe array literal notation.

A

const arrayName = [ value1, value2,… etc ];

25
Q

How are arrays different from “plain” objects?

A

An array is a list of values assigned to a variable

An object is a list of properties assigned to a variable

26
Q

What number represents the first index of an array?

A

0

27
Q

What is the length property of an array?

A

Lists how long the array is

28
Q

How do you calculate the last index of an array?

A