JavaScript Flashcards

1
Q

What is the purpose of variables?

A

The purpose of a variable is to store data types.

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 then the name of the variable.

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

Using the = 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, digits, underscore, dollar sign

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 that capital and lower case names of variables aren’t the same.

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

Strings are used to work with any kind of 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

Numbers are used to calculate things and to determine the size of things.

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

Booleans are true or false. Helps determine which part of a script should run.

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

= is an 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

Just assign a new value to the already created variable.

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 when a variable doesn’t have a value but can be updated later.

Undefined means the variable was declared without assigning a value.

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

So you will know what that line of code does later on when you come back to it. Also for other people working on your code in the future.

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, null.

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

What are objects used for?

A

Objects group together a set of variables and functions to create a model.

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

What are object properties?

A

They are variables or functions that are within the object literal.

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

Describe object literal notation.

A

An object literal uses the curly braces to hold properties and their values.

17
Q

How do you remove a property from an object?

A

Use the delete keyword followed by the object name and property name.

18
Q

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

A

Dot notations and Bracket notations.

19
Q

What are arrays used for?

A

Arrays are used to hold a list of values that are releate to each other.

20
Q

Describe array literal notation.

A

An array literal notation comes after the variable is declared. Uses brackets to store data.

21
Q

How are arrays different from “plain” objects?

A

Arrays store a list of values that are related. While objects store variables and functions that are related to the object.

22
Q

What number represents the first index of an array?

A

0 represents the first index.

23
Q

What is the length property of an array?

A

The length property counts how many values are in the array.

24
Q

How do you calculate the last index of an array?

A

The last index of the array is array.length - 1.