JavaScript Flashcards
(127 cards)
What is the purpose of variables?
Variables can hold any data value and can changed anytime
How do you declare a variable?
You declare using var (keyword) and variable name
How do you initialize (assign a value to) a variable?
=
What characters are allowed in variable names?
Letter, dollar sign, and underscore to start and numbers
What does it mean to say that variable names are “case sensitive”?
First letter shouldn’t be capitalize and every letter capitalized after is different string value than the non-capitalized string values.
What is the purpose of a string?
To hold values as letters/text and change
What is the purpose of a number?
To hold values as numbers for arithmetic
What is the purpose of a boolean?
To hold values of true or false for decision making
What does the = operator mean in JavaScript?
Putting a value into something
How do you update the value of a variable?
Assign a new value
What is the difference between null and undefined?
They both represent empty value but null is empty on purpose - it has to be assigned to something while undefined is not assigned a value.
Why is it a good habit to include “labels” when you log values to the browser console?
Gives us point of reference
Give five examples of JavaScript primitives
String, boolean, number, null, undefined, symbol
What data type is returned by an arithmetic operation?
numeric data type
What is string concatenation?
Process of joining together two or more strings
What purpose(s) does the + plus operator serve in JavaScript?
Addition and string concatenation
What data type is returned by comparing two values (, ===, etc)?
Boolean data type
What does the += “plus-equals” operator do?
adds the value of the additional data value to a variable and assigns the result to the variable
What are objects used for?
Object groups a set of variables(properties) and functions(methods) to create a model.
What are object properties?
Variables that are part of the object
Describe object literal notation.
{} with whatever properties : method name
How do you remove a property from an object?
with the delete operator
What are the two ways to get or update the value of a property?
Dot or bracket notations
What are arrays used for?
Array is used to store list of values and indexed with set order