JavaScript variables Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

General rules for naming variables

A
  • cannot start with numbers
  • case sensitive
  • cannot be the same as keywords
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a variable

A

It is a container for a value.

- It holds reusable data in a program and associates it with a name

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

var

A
a key word that declares new variable
var myName = 'Bethani';
console.log(myName);
// Output: Bethani 

In this case, key word variable is being used.

  • var is declaring the variable myName
  • Bethani is the value being assigned to myName
  • After the variable is declared, the string value ‘Bethani’ is printed to the console.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Where are variables stored

A

In memory

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

Preferred variable keywords

A

let is the preferred way to declare a variable for reassigning and const when you want it to remain constant

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

When variables have not been initialized

A

they store the primitive data type undefined.

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

Mathematical assignment operators and variables

A

make it easy to calculate a new value and assign it to the same variable

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

+ operator used for what in variables

A

used to concatenate strings held in variables

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

Since ES6 what are backticks ` and ${} used for

A

` backticks
${} placeholder
- used to interpolate values into a string.

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

typeof keyword

A

returns the data type (as a string) of a value

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