JavaScript Flashcards
What is a variable?
A way to hold data
Why are variables useful?
It can hold data that changes
What two special characters can a variable begin with?
dollar sign and underscore
How do you declare a variable?
Using the keyword “var”
How do you assign a value to a variable?
With the assignment operator “=”
Are variables case sensitive?
Yes
Which words cannot be used as variable names?
can’t start with a digit, no punctuation or special characters, keywords
What is a string?
datatype to represent text stored with quotation marks
What is the string concatenation operator?
+
What is the difference when it comes to using single quotes or double quotes ( ‘ ‘ or “ “ )?
No difference, but has to start and end with same quote
How do you escape quotation characters?
Backslash before the quote to let the interpreter know that it is part of the string instead the end of it.
What is type coercion?
JS will convert that value to the type it needs
What is a number in JavaScript?
Numeric Values
What is an arithmetic operator?
Operators can do math
Name four of the arithmetic operators?
+ (addition), - (subtraction), * (multiplication), / (division) %(remainder, modulus)
What is the order of execution?
By precedence - mult, div, comes first. Parenthesis overpowers everything.
What is a boolean?
data type that is true or false
What is a comparison operator?
> < and it returns a boolean
What is the difference between undefined and null?
undefined is an absence of a value, null is intentional absence of object value
What is a function?
group a series of statements together to perform a specific task
Why are functions useful?
reusable code
How do you call a function?
function name ( )
What are the parts of a function definition?
function keyword, function name, parameter, code block
What is the difference between a parameter and an argument?
declaring a function they are parameters and calling a function they are arguments
What is the difference between null and undefined?
Null is an object and undefined is undefined
Why do you always use === for comparisons?
Due to type coercion
Do all if statements require an else statement?
No
What is the proper syntax for using the or operator?
|
What is the primary use case for switches?
Comparing a value to many values
Does the default case have to be at the bottom of the switch statement?
No it can jump back to the default
What happens if there is no break statement between cases?
It will continually run all cases even if it’s met
What is an object in JavaScript?
Set of variables and functions / collection of related data
How do you create an object literal?
curly braces, and its contents
What is a property in relation to JavaScript objects?
variables
How do you remove a property from an object?
delete keyword object name and property
When should you use bracket notation over dot notation with objects?
variable that you need to substitute
What is an array in JavaScript?
list or set of values that are related to each other that are ordered.
How do you create an array literal?
[ ]
What are the keys for the values inside an array?
index number
Arrays have a property named length. Because arrays have a properties, what other data structure are they similar to?
objects