javascript Flashcards
What is the purpose of variables?
Store data and information.
How do you declare a variable?
Start with a variable keyword, followed by the variable name and followed by a semicolon.
How do you initialize (assign a value to) a variable?
use an assignment operator (=)
What characters are allowed in variable names?
a-z(case sensitive), _(underscore), dollar sign, camel case, numbers.
What does it mean to say that variable names are “case sensitive”?
App vs app means two different variables.
What is the purpose of a string?
Store text data and They are frequently used to add
new content into a page and they
can contain HTML markup.
What is the purpose of a number?
Calculating. determining the size of the screen, moving the position of an element on a page, or setting the amount of time an element should take to fade in.
What is the purpose of a boolean?
true or false.
What does the = operator mean in JavaScript?
assign the value
How do you update the value of a variable?
assign another value?
What is the difference between null and undefined?
null is an assigned value, undefined means there is a declared available but not defined.
Why is it a good habit to include “labels” when you log values to the browser console?
It will be easier to locate the data you are looking for.
Give five examples of JavaScript primitives.
string, number, boolean, undefined, and null.
What are objects used for?
store data
What are arrays used for?
store a collection of data such as lists
What number represents the first index of an array?
0
What is the length property of an array?
the name of the array.length
What is a function in JavaScript?
A block of code that can be stored and reused.