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.
Describe object literal notation.
An object literal uses the curly braces to hold properties and their values.
How do you remove a property from an object?
Use the delete keyword followed by the object name and property name.
What are the two ways to get or update the value of a property?
Dot notations and Bracket notations.
What are arrays used for?
Arrays are used to hold a list of values that are releate to each other.
Describe array literal notation.
An array literal notation comes after the variable is declared. Uses brackets to store data.
How are arrays different from “plain” objects?
Arrays store a list of values that are related. While objects store variables and functions that are related to the object.
What number represents the first index of an array?
0 represents the first index.
What is the length property of an array?
The length property counts how many values are in the array.
How do you calculate the last index of an array?
The last index of the array is array.length - 1.