JavaScript variables Flashcards Preview

Data Science for beginners > JavaScript variables > Flashcards

Flashcards in JavaScript variables Deck (10)
Loading flashcards...
1
Q

General rules for naming variables

A
  • cannot start with numbers
  • case sensitive
  • cannot be the same as keywords
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

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.
4
Q

Where are variables stored

A

In memory

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

6
Q

When variables have not been initialized

A

they store the primitive data type undefined.

7
Q

Mathematical assignment operators and variables

A

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

8
Q

+ operator used for what in variables

A

used to concatenate strings held in variables

9
Q

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

A

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

10
Q

typeof keyword

A

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