JavaScript Flashcards
What is the purpose of variables?
The purpose of a variable is to store data types.
How do you declare a variable?
Var then the name of the variable.
How do you initialize (assign a value to) a variable?
Using the = sign.
What characters are allowed in variable names?
letters, digits, underscore, dollar sign
What does it mean to say that variable names are “case sensitive”?
It means that capital and lower case names of variables aren’t the same.
What is the purpose of a string?
Strings are used to work with any kind of text.
What is the purpose of a number?
Numbers are used to calculate things and to determine the size of things.
What is the purpose of a boolean?
Booleans are true or false. Helps determine which part of a script should run.
What does the = operator mean in JavaScript?
= is an assignment operator.
How do you update the value of a variable?
Just assign a new value to the already created variable.
What is the difference between null and undefined?
Null is when a variable doesn’t have a value but can be updated later.
Undefined means the variable was declared without assigning a value.
Why is it a good habit to include “labels” when you log values to the browser console?
So you will know what that line of code does later on when you come back to it. Also for other people working on your code in the future.
Give five examples of JavaScript primitives.
String, number, boolean, undefined, null.
What are objects used for?
Objects group together a set of variables and functions to create a model.
What are object properties?
They are variables or functions that are within the object literal.