JavaScript Flashcards
What is the purpose of variables?
stores data value that can be changed and used later on
How do you declare a variable?
using var keyword.
How do you initialize (assign a value to) a variable?
var keyword, variable name, assignment operator, and value.
What characters are allowed in variable names?
variable names cannot contain any spaces. Must start with a letter, underscore, or dollar sign. names can only contain letters, numbers, underscores, or dollar signs. names are case sensitive.
What does it mean to say that variable names are “case sensitive”?
means any identifier must be typed with a consistent capitalization of numbers.
What is the difference between null and undefined?
null is representation of no value, undefined means a variable has been declared but not yet has been assigned a value.
Why is it a good habit to include “labels” when you log values to the browser console?
so that you know what is being logged.
Give five examples of JavaScript primitives.
strings, numbers, null, undefined, boolean
What data type is returned by an arithmetic operation?
numbers
What is string concatenation?
joining string together.
What purpose(s) does the + plus operator serve in JavaScript?
for concatenation and adding numeric values together
What data type is returned by comparing two values (< , >, ===, etc)?
boolean value
What does the += “plus-equals” operator do?
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 variable and functions to create a model of something.
What are object properties?
a variable that is part of an object.
Describe object literal notation.
var keyword, variable name, assignment operator, key value pairs.
How do you remove a property from an object?
use delete keyword followed by the object name and property name.
What are the two ways to get or update the value of a property?
object name, dot notation, followed by property name, assignment operator and property value. object name, square bracket, property name in string assignment operator, and property value.
What are arrays used for?
a list or set of values that are related to each other. Making lists of related of the exact same type.
What number represents the first index of an array?
0.
What is the length property of an array?
gives the number of items in array.
How do you calculate the last index of an array?
array.length - 1.
Describe array literal notation.
var keyword, variable name, assignment operator, square bracket, array values.
How are arrays different from “plain” objects?
arrays keys are index, object keys are properties.