JavaScript Flashcards
What is the purpose of variables?
Stores data
How do you declare a variable?
Variable keyword + variable names = variable value;
Must give variable a name
How do you initialize (assign a value to) a variable?
Assign the value using an assignment operator
= sign
What characters are allowed in variable names?
$ or underscore
What does it mean to say that variable names are “case sensitive”?
camelCase - first word lowercase, any additional words have first letter capitalized
What is the purpose of a string?
Working with any kind of text to add new content to a page
Can contain HTML markup
What is the purpose of a number?
Involves counting or calculating sums
Numeric values
What is the purpose of a boolean?
Give values of true or false
Helps determine which part of the script should run
What does the = operator mean in JavaScript?
Assignment operator
Assigns names to value
How do you update the value of a variable?
Change the value
What is the difference between null and undefined?
Null: intentional absence of the value. Undefined: It means the value does not exist in the compiler.
Why is it a good habit to include “labels” when you log values to the browser console
Name of what is for
helps self and others to define what it is used for
Give five examples of JavaScript primitives.
undefined, null, boolean, string, and number
What data type is returned by an arithmetic operation?
Numeric
What is string concatenation?
Process of joining two or more strings to create one new string
What purpose(s) does the + plus operator serve in JavaScript?
Addition as well as concatenation
What data type is returned by comparing two values (, ===, etc)?
Comparison operators
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 arrays used for?
Storing values as a list
Describe array literal notation.
Values assigned to the array inside of a pair of square brackets, each value separated by a comma.
Don’t need to be same data type
How are arrays different from “plain” objects?
Can combine arrays and objects to create a data structure
What number represents the first index of an array?
0
What is the length property of an array?
sets or returns the number of elements in an array
How do you calculate the last index of an array?
Name.length - 1