JavaScript Flashcards
What is the purpose of variables?
Variables are for storing bits of information.
How do you declare a variable?
Variables are declared using the variable keyword and variable name. For example, var quantity; is a variable declaration.
How do you initialize (assign a value to) a variable?
Variables are initialized by using the assignment operator ‘=’.
What characters are allowed in variable names?
Variable names will accept letters, numbers, dollar signs, and underscores. However, variable names cannot start with a number.
What does it mean to say that variable names are “case sensitive”?
This means that language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.
What is the purpose of a string?
The purpose of a string is to store and manipulate text.
What is the purpose of a number?
Numbers are primarily used for arithmetic expressions.
What is the purpose of a boolean?
A boolean denotes a true or false value which allows a program to analyze and respond to conditions.
What does the = operator mean in JavaScript?
The = operator is used to assign values to variables.
How do you update the value of a variable?
You can update the value of a variable by using the assignment operator to store a new value.
What is the difference between null and undefined?
A null value is assigned intentionally, whereas a value of undefined is typically given by JavaScript.
Why is it a good habit to include “labels” when you log values to the browser console?
Labels improve readability and aids in debugging when you log values to the browser console.
Give five examples of JavaScript primitives.
String, number, boolean, null, and undefined are five examples of JavaScript primitives.
What data type is returned by an arithmetic operation?
An arithmetic operation returns a data type of number.
What is string concatenation?
Concatenation is the process of appending one string to the end of another string.
What purpose(s) does the + plus operator serve in JavaScript?
The + plus operator is used to perform addition in JavaScript. You can also concatenate strings by using the + plus operator.
What data type is returned by comparing two values (, ===, etc)?
Comparing two values will return a data type of boolean.
What does the += “plus-equals” operator do?
The addition assignment operator (+=) adds the value of the right operand to a variable and assigns the result to the variable.
What are objects used for?
Objects group together a set of variables and functions to create a model of a something you would recognize from the real world.
What are object properties?
A property is a variable within an object.
Describe object literal notation.
The object literal notation is basically an array of key:value pairs, with a colon separating the keys and values, and a comma after every key:value pair, except for the last.
How do you remove a property from an object?
You can remove a property from an object using the delete keyword.
What are the two ways to get or update the value of a property?
You can use dot and bracket notation to get or update the value of a property.
What are arrays used for?
An array is used to store a list of values.