javascript-primitives-and-variables Flashcards

1
Q

What is the purpose of variables?

A

to store information that can be used later

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

How do you declare a variable?

A

let {variable_name} = {information} , const or var

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

declare the variable ( let, const, var ) then the = sign then the information

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

any combination of letter, digit, or symbols $ and _ , it cannot begin with a number.

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

The capitalization of the variable name must match. If you create two variables with different capitalization you have created two separate variables.

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

a string is used to store text that is in a human readable format

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 to store a number that can be used for calculations

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

a boolean is used to store the result of a condition. It has two options, 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 used to assign a value to a variable

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

you can update by using the assigmnet operator ‘=’

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 a value that represents the absence of an object. It is typically used to indicate that a variable does not refer to an object, or that a function does not return an object.

undefined is a value that indicates that a variable has not been assigned a value. If you try to access a variable that has not been declared or assigned a value, it will have the value undefined.

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

Labels help to distignuish the values from eachother

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

Give five examples of JavaScript primitives.

A

In JavaScript, a primitive is a data type that is not an object and has no methods.

number: This data type represents numeric values, such as integers (e.g. 1, 2, 3) and floating-point numbers (e.g. 1.5, 2.3, 3.14).

string: This data type represents a sequence of characters, such as words, sentences, and paragraphs. Strings are enclosed in quotes (either single or double).

boolean: This data type has only two values: true and false. It is commonly used in conditional statements to test for certain conditions.

null: This data type has only one value: null. It represents the absence of an object.

undefined: This data type has only one value: undefined. It indicates that a variable has not been assigned a value.

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