JavaScript Flashcards
What is the purpose of variables?
To store information to be accessed later on.
How do you declare a variable?
By using var , let, or const followed by the name of the variable.
How do you initialize (assign a value to) a variable?
By declaring a variable and then using the equal sign.
What characters are allowed in variable names?
letters, numbers, dollar signs
What does it mean to say that variable names are “case sensitive”?
it means A and a are different
What is the purpose of a string?
The purpose of a string is to work with text and can contain HTML markup.
What is the purpose of a number?
To have a value that can be calculated. But also to determine screen sizes or an amount of time for an element to do something.
What is the purpose of a boolean?
To help determine when someone needs to happen or not. 1 or 0.
What does the = operator mean in JavaScript?
The equal sign operator means assign.
How do you update the value of a variable?
You would simply type the variable again without the var and assign a new value to it.
What is the difference between null and undefined?
Null is developer intended, while undefined is unintended.
Why is it a good habit to include “labels” when you log values to the browser console?
There will be many logs when the codes get more in depth and things can get confusing. Simply, its for readability.
Give five examples of JavaScript primitives.
string, number, boolean, undefined, null
What data type is returned by an arithmetic operation?
A numerical value
What is string concatenation?
It’s when a string is added to another string or the value of a variable.
What purpose(s) does the + plus operator serve in JavaScript?
concatenation
What data type is returned by comparing two values (greater than, less than, ===, etc)?
Operands are being compared
What does the += “plus-equals” operator do?
It is the addition assignment. It adds the current value of something to the variable or number and the result of that expression is updated to the given variable.
What are objects used for?
Objects group together a set of variables and functions to create a model.
What are object properties?
Object properties are essentially variables.
Describe object literal notation.
An object literal notation contains an opening curly brace that holds key value pairs, followed by a closing curly brace.
How do you remove a property from an object?
By using the delete operator followed by the object name and the property name.
What are the two ways to get or update the value of a property?
By typing the object name followed by the member operator (.) followed by the assignment operator (=), followed by the new property value.
By typing the object name followed by the property name inside the square brackets followed by the equal sign and the new property value.
What are arrays used for?
Arrays are used to hold things like a shopping list or something that are closely related that can be referenced by index numbers.