JS week 1 day 1 Flashcards

1
Q

What is the purpose of variables?

A

variable stores the data value that can be changed later on

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

How do you declare a variable?

A

use keyword var, let or const

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

by using = 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

letters, underscore, dollar sign, subsequent characters can be numbers, no spaces

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

if variable names include same letters but one cases do not match, strings values do not equate to each other

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

JavaScript strings are used for storing and manipulating 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

to perform arithmetic operations, and describe/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

Booleans are used as functions to get the values of variables, objects, conditions, and expressions. true/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

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

remove the declaration key word, variable name = “different value”

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

undefined means a variable has been declared but has not yet been assigned a value. null is an assignment value but can be assigned to a variable as a representation of no value. ( null = intentional absence of 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

to help debug

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

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

appends one string to the end of another 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

addition operator

17
Q

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

18
Q

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

A

The addition assignment operator ( += ) adds the value of the right operand to a variable and assigns the result to the variable.

19
Q

What are objects used for?

A

to group together a set of variables and functions to create a model of something. In JavaScript, almost “everything” is an object.

20
Q

What are object properties?

A

Properties are the values associated with a JavaScript object. (If a variable is part of an object, it is called properties)

21
Q

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

A

using dot or bracket notation

22
Q

Describe object literal notation.

A

curly braces assigned to variable.

23
Q

How do you remove a property from an object?

A

delete operator

24
Q

What are arrays used for?

A

arrays are used to store list of values.

25
What number represents the first index of an array?
0
26
How are arrays different from "plain" objects?
objects are used to store collection of data and arrays are used to store list of values. arrays are numerically indexed and objects are not ordered.
27
What is the length property of an array?
length property returns number of elements in an array.