JavaScript Flashcards
What is the purpose of variables?
To store data.
How do you declare a variable?
Variable keyword followed by the variable name.
How do you initialize (assign a value to) a variable?
Variable name followed by an assignment operator followed by a variable value.
What characters are allowed in variable names?
letters, numbers, dollar sign, or an underscore. Cannot use dash or a period in a variable name. Cannot use reserved words like var. Cannot start with numbers.
What does it mean to say that variable names are “case sensitive”?
variables, functions, and any other identifiers must be typed with consistent capitalization of letters.
What is the purpose of a string?
holding data that can be represented in text form. To save a series of characters.
What is the purpose of a number?
to represent and manipulate numbers. Represent numeric value. Math, a measurement.
What is the purpose of a boolean?
datatype that returns either true or false. To make decisions. Allow you to tell the computer do or don’t do.
What does the=operator mean in JavaScript?
assignment operator. Putting a value to something.
How do you update the value of a variable?
variable name assignment operator and value
What is the difference between null and undefined?
undefined is a variable thats not assigned to anything. null is when purposely assigned a value of nothing until give value later.
Why is it a good habit to include “labels” when you log values to the browser console?
to label value to know what value belongs to which variable.
Give five examples of JavaScript primitives.
string, number, boolean, undefined, null.
What data type is returned by an arithmetic operation?
number
What is string concatenation?
joining strings together. Combination of two or more string values.
What purpose(s) does the+plus operator serve in JavaScript?
adds one value to another. Adding number values or concatenation.
What data type is returned by comparing two values (.===.etc)?
boolean
What does the += “plus-equals” operator do?
adds the value on the right, to the variable on the left, and then assigns that value back into the variable on the left.
What are objects used for?
objects group together a set of variables and functions to create a model of something. Allows us to store data together. Create collection of stuff.
What are object properties?
Individual data stored in object.
Describe object literal notation.
the object is the curly braces and their contents. The object is stored in a variable. Separate each property from its value using a colon. Separate each property and method with a comma.
How do you remove a property from an object?
to delete a property, 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?
using the dot notation or the square brace.
What are arrays used for?
when working with a list or a set of values that are related to each other.