Variables, Declarations, Initializations, and DataTypes Flashcards
Name 3 variable keywords.
var
let
const
What is a variable?
A variable is a named container used for storing data or values.
Write an example of a variable.
let fruit = ‘apple’;
Is var hello = ‘hello’; the same as var Hello = ‘hello’; ?
Nope! Variable naming is case sensitive.
var hello is a different variable than var Hello.
When do we use the keyword ‘const’?
We use the keyword ‘const’ to create a variable of which we don’t want the value to be able to be changed or altered at any given time.
Time to deconstruct a variable. For example: let b = 1;
What are the names of the 4 components that create a variable?
1 - Keyword
2 - Variable Name
3 - Assignment Operator
4 - Variable Value
What does the left hand side of a variable refer to?
let x ;
The left hand side of a variable is called the ‘declaration’. It is simply the variable keyword and the variable name.
What does the right hand side of a variable refer to?
x = 10 ;
The right hand side of a variable is called the ‘initialization’. It includes the variable name, assignment operator, and the value of the variable.
Name the 6 basic data types in JavaScript we covered in class and write an example for each of them.
- Boolean: let boolean = true;
- Number: let num = 14;
- String: let string = ‘Hello’;
- Null: let nothing = null;
- Undefined: let undef = undefined;
- Object: let food = [‘pizza’, ‘shrimp’];
What does JavaScript use to join strings?
In JavaScript, we can use concatenation to join strings together to build sentences.
Which method uppercases all the letters in a string?
Methods are tools that allow us to manipulate data.
myName.toUpperCase( ) ;
How do you make a directory through the command line?
mkdir
How do you check what folders you can access in the command line?
ls (for mac)
dir (for pc)
How do you change directories in the command line?
cd
How do you back up one directory in the command line?
cd ..