JavaScript Flashcards
What is the purpose of variables?
Storing values
How do you declare a variable?
Using the var keyword
How do you initialize (assign a value to) a variable?
Var x = 89;
What characters are allowed in variable names?
Underscores, $. Numbers and letters
What does it mean to say that variable names are “case sensitive”?
The uppercase or lowercase letter refers to different values
What is the purpose of a string?
To store or manipulate text letters and sentences
What is the purpose of a number?
To store and manipulate numbers and decimals
What is the purpose of a boolean?
True or false for conditionals, loops
What does the = operator mean in JavaScript?
Assigning a value to a variables
How do you update the value of a variable?
Use the variable name and the equal sign and assign the value
What is the difference between null and undefined?
Null is an intentional no value, and undefined is not intentional
Why is it a good habit to include “labels” when you log values to the browser console?
For clarity to understanding what the console is working on, point of reference
Give five examples of JavaScript primitives.
String numbers boolean null undefined
What data type is returned by an arithmetic operation?
numeric, numbers
What is string concatenation?
adding strings together
What purpose(s) does the + plus operator serve in JavaScript?
Add numbers and concatenating strings
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
adding to the value of the variables
What are objects used for?
Containers for keeping information
What are object properties?
The keys that give information about the object
Describe object literal notation.
{} property:value
How do you remove a property from an object?
delete keyword
What are the two ways to get or update the value of a property?
[] or dot notation
What are arrays used for?
to store multiple items
Describe array literal notation.
[] separated by “,”
How are arrays different from “plain” objects?
it can be indexed by numbers starting from 0
What number represents the first index of an array?
0
What is the length property of an array?
calculate the size of the array
How do you calculate the last index of an array?
length -1
What is a function in JavaScript?
A process that can be used and called to perform that same process.
Describe the parts of a function definition.
The name of the function, the function keyword, parameter list., code block, return statement.
Describe the parts of a function call.
Name of the function () arguments in the parenthesis.
When comparing them side-by-side, what are the differences between a function call and a function definition?
Function calls require actual values, while function definitions require a name or variables, and function keyword.
What is the difference between a parameter and an argument?
Parameters are the name that is given o the piece of data that will give, later on, arguments are the actual values that are being passed on to the function.
Why are function parameters useful?
To be empty conatainers to hold values for the upcoming values
What two effects does a return statement have on the behavior of a function?
It makes the value of the function a value that is not undefined.
Why do we log things to the console?
Debugging and for clarity.
What is a method?
A function that is being stored as a property.