prep-javascript-variables, objects, and arrays Flashcards

1
Q

What does the = (equals) operator do in JavaScript?

A

The = (equals) operator in JavaScript is an assignment operator. It assigns the value of the variable(s) on the right side of the = (equals) operator to the variable on the left side of the = (equals) operator.

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

Which keyword is used to declare a variable in JavaScript?

A

var, let, or const

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

Which characters is a JavaScript variable allowed to begin with?

A

A letter, $, or _

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

What are quotation marks used for in JavaScript?

A

To create string values

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

What is the purpose of strings in JavaScript?

A

To hold text values like “John Doe” in a variable,

and

JavaScript strings are for storing and manipulating text.

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

What is the purpose of booleans in JavaScript?

A

JavaScript booleans are often used to find out if an expression or variable is true or not

Ex: “Boolean(10 > 9)” would return the boolean value of “true”.

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

What is the purpose of numbers in JavaScript?

A

The purpose of numbers in JavaScript is to store numeric values (decimal and non-decimal) in variables.
Arithmetic operations can be performed on these variables that hold numeric values such as addition, subtraction, division, modulo, etc.

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

What does null mean in JavaScript?

A

“null” means an object has no value.
An object can be assigned “null” to show that it has no value.
This is different from “undefined” because “undefined” means that a value has not been set for a variable when the variable was declared.

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

What data types can object properties hold?

A

strings, numbers, arrays, booleans, functions

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

Describe the syntax (structure) of object-literals in JavaScript.

A

Ex: const person = {firstName: “John”, lastName: “Doe”, age: 50, eyeColor: “blue”};

The syntax of object-literals consists of the use of the keyword “const” followed by the variable name; and it is assigned the properties and property values to the right of the equal (=) sign operator, which are separated by commas inside curly braces.

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

What is the principal use of arrays?

A

To store “list” type data in a numerically indexed data structure, which is zero-indexed.

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

Describe the syntax (structure) of array-literals in JavaScript.

A

const array_name = [item 1, item 2, …];

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

What number represents the first index of an array?

A

0

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

How can you access the last element of an array?

A

lastElement = myArray[myArray.length - 1];

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