Javascript Flashcards
What is the purpose of variables?
storing data
How do you declare a variable?
Var name =
How do you initialize (assign a value to) a variable?
assignment operator
What characters are allowed in variable names?
number, text, $, _ cannot start with a number.
What does it mean to say that variable names are “case sensitive”?
capitalizing letters will affect the variable.
What is the purpose of a string?
To add any kind of text.
What is the purpose of a number?
for tasks relating to counting or calculating
What is the purpose of a boolean?
To store a true or false/ determining which part of a script should run.
What does the = operator mean in JavaScript?
Assignment operator
How do you update the value of a variable?
by writing the variable name and assigning it a new value
What is the difference between null and undefined?
undefined = (a variable that has been declared, but no value has been assigned to it yet) null = a variable with no value - it may have had one at some point, but no longer has a value
Why is it a good habit to include “labels” when you log values to the browser console?
So you or your readers can understand what is displayed.
Give five examples of JavaScript primitives.
string, number, boolean, undefined, null
What are objects used for?
grouping together a set of variables and functions. Used to model things.
What are object properties?
variables that are part of an object.
Describe object literal notation.
A way of creating objects by setting variables inside of curly braces.
How do you remove a property from an object?
use the delete keyword followed by the object name . and property name.
What are the two ways to get or update the value of a property?
dot notation or square brackets
What data type is returned by an arithmetic operation?
number type
What is string concatenation?
Combining two or more strings
What purpose(s) does the + plus operator serve in JavaScript?
Adds one value to another or concatenating strings
What data type is returned by comparing two values (, ===, etc)?
Booleans
What does the += “plus-equals” operator do?
add content to an existing variable.
What are arrays used for?
Storing a list of values
Describe array literal notation.
var blank = [‘…’, ‘…’, ‘…’]
How are arrays different from “plain” objects?
They store a list of values instead of just one.
What number represents the first index of an array?
[0]
What is the length property of an array?
determines length of array (how many properties are in it)
How do you calculate the last index of an array?
subtract 1 from the total number of index values.
What is a function in JavaScript?
Similar to a procedure takes some input and returns output
Describe the parts of a function definition.
Describe the parts of a function call.
writing the name of the function and placing () parentheses next to it
Why do we log things to the console?
To check output
What is Method?
Function which is the property of an object.
How is a method different from any other function?
Both are objects but a method is a object reference to a function.