JavaScript 0130 Flashcards
What is the purpose of variables?
*To have a place to store data to be used later
How do you declare a variable?
using an assignment operator, e.g. “var”, and naming it within the confines of naming. it does not need to be initialized/assign to be declared
How do you initialize (assign a value to) a variable?
initialize is assign. use “=” and then assign its value
What characters are allowed in variable names?
$ _ letters numbers
What does it mean to say that variable names are “case sensitive”?
e.g. fullname and fullName are two different variables
What is the purpose of a string?
for text content
What is the purpose of a number?
store numbers to be used for things like calculation
What is the purpose of a boolean?
for decision making
What does the = operator mean in JavaScript?
it is used for declaring varables
How do you update the value of a variable?
type its name, then “=”, then the new value
What is the difference between null and undefined?
und var is not defined, null is like a placeholder
Why is it a good habit to include “labels” when you log values to the browser console?
so you can distinguish them in the console
Give five examples of JavaScript primitives.
number, string, bulion, undefined, null
What data type is returned by an arithmetic operation?
a number
What is string concatenation?
joining data (strings?) with the + operator
What purpose(s) does the + plus operator serve in JavaScript?
to add numbers in calculations, to join data thru concatenation