JS week 1 day 1 Flashcards
What is the purpose of variables?
variable stores the data value that can be changed later on
How do you declare a variable?
use keyword var, let or const
How do you initialize (assign a value to) a variable?
by using = operator
What characters are allowed in variable names?
letters, underscore, dollar sign, subsequent characters can be numbers, no spaces
What does it mean to say that variable names are “case sensitive”?
if variable names include same letters but one cases do not match, strings values do not equate to each other
What is the purpose of a string?
JavaScript strings are used for storing and manipulating text.
What is the purpose of a number?
to perform arithmetic operations, and describe/store numeric values.
What is the purpose of a boolean?
Booleans are used as functions to get the values of variables, objects, conditions, and expressions. true/false
What does the = operator mean in JavaScript?
assignment operator
How do you update the value of a variable?
remove the declaration key word, variable name = “different value”
What is the difference between null and undefined?
undefined means a variable has been declared but has not yet been assigned a value. null is an assignment value but can be assigned to a variable as a representation of no value. ( null = intentional absence of value)
Why is it a good habit to include “labels” when you log values to the browser console?
to help debug
Give five examples of JavaScript primitives.
string, number, boolean, null, undefined
What data type is returned by an arithmetic operation?
number
What is string concatenation?
appends one string to the end of another string
What purpose(s) does the + plus operator serve in JavaScript?
addition operator
What data type is returned by comparing two values (, ===, etc)?
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?
to group together a set of variables and functions to create a model of something. In JavaScript, almost “everything” is an object.
What are object properties?
Properties are the values associated with a JavaScript object. (If a variable is part of an object, it is called properties)
What are the two ways to get or update the value of a property?
using dot or bracket notation
Describe object literal notation.
curly braces assigned to variable.
How do you remove a property from an object?
delete operator
What are arrays used for?
arrays are used to store list of values.
What number represents the first index of an array?
0
How are arrays different from “plain” objects?
objects are used to store collection of data and arrays are used to store list of values. arrays are numerically indexed and objects are not ordered.
What is the length property of an array?
length property returns number of elements in an array.