Variables Flashcards

1
Q

What is let ?

A

One of the keyword used when you want to declare a variable that is might be reassigned

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

What is const ?

A

One of the keyword used when you want to declare a variable with a constant value

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

What are the keywords possible for a variable?

A

Var : used pre-ES6 versions of JS
Let : variable can be reassigned a different value
Const : variable cannot be reassigned because it is constant

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

What happens when a variable has not been initialized ?

A

The primitive data type is going to be store undefined

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

What happens if you try to reassign a
const variable?

A

You’ll get aTypeError

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

What happens if you try to declare aconstvariable without a value?

A

You’ll get aSyntaxError

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

When do you get aSyntaxError?

A

If you try to declare a const variable without a value

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

When do you get a TypeError?

A

If you try to reassign aconstvariable

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

When do you get automatically a value ofundefined?

A

If we don’t assign a value to a variable declared using theletkeyword

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

What happens If we don’t assign a value to a variable declared using theletkeyword?

A

It automatically has a value of undefined

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

What are the few general rules for naming variables?

A
  • Variable names cannot start with numbers.
  • Variable names are case sensitive, somyNameandmynamewould be different variables. It is bad practice to create two variables that have the same name using different cases.
  • Variable names cannot be the same askeywords.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is = ?

A

An assignment operator

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

What is what ?
var myName =’Arya’;

A
  1. var, short for variable, is a JavaScriptkeywordthat creates, ordeclares, a new variable.
  2. myNameis the variable’s name.
  3. =is theassignment operator. It assigns the value ('Arya') to the variable (myName).
  4. 'Arya'is thevalueassigned (=) to the variablemyName
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a variable?

A

Avariableis a container for a value.
Variables also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves.
In short, variables label and store data in memory

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

What can you do with variables ?

A
  1. Create a variable with a descriptive name.
  2. Store or update information stored in a variable.
  3. Reference or “get” information stored in a variable.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are NOT variables?

A

Variables are not values

17
Q

What is var ?

A

Var : used pre-ES6 versions of JS
Short for variable, is a JavaScriptkeywordthat creates, ordeclares, a new variable.

18
Q

What is the increment operator ?

A

It’s ++

19
Q

What is the decrement operator ?

A

It’s –

20
Q

What are The Increment and Decrement Operator?

A

They are two of mathematical assignment operators. You can use them to update the variable’s valueandassigned as the new value of that variable.
Increment operator is (++)
Decrement operator is(–).

21
Q

Mathem

A

We can use variables and math operators to calculate new values and assign them to a variable

22
Q

How can we use the + operator?

A

The+operator is used to concatenate strings including string values held in variables.

23
Q

What do you use to interpolate values into a string ?

A

Template literals use backticks`and${}

24
Q

What is thetypeofkeyword for ?

A

Returns the data type (as a string) of a value.