JavaScript Flashcards
What is the purpose of variables?
Give the browser a short term memory of certain bits. to use later on.
How do you declare a variable?
var keyword: var name = var value;
How do you initialize (assign a value to) a variable?
var name = value; use single equal signs
What characters are allowed in variable names?
letters and dollar signs and underscore and number but you cant start with number
What does it mean to say that variable names are “case sensitive”?
lower and upper cases matter (cats is not the same as Cats)
What is the purpose of a string?
to store text
What is the purpose of a number?
to store numbers
What is the purpose of a boolean?
give data either true or false. logic with binary state, on/off
What does the = operator mean in JavaScript?
assignment operator
How do you update the value of a variable?
variable name = new value;
What is the difference between null and undefined?
null if intentional missing of data where as undefined is missing where its suppose to be
Why is it a good habit to include “labels” when you log values to the browser console?
to know which variables if logging and which is not to make it easier to debug code and read.
Give five examples of JavaScript primitives.
Number, null, undefined, Boolean, string, array , object
What data type is returned by an arithmetic operation?
number
What is string concatenation?
the process of combining multiply strings into one
What purpose(s) does the + plus operator serve in JavaScript?
additions in numeric values or concationate strings
What data type is returned by comparing two values (, ===, etc)?
Booleons
What does the += “plus-equals” operator do?
it add the data to the variables and set the new value as the variables
(num = num + 10 is the same num += 10)
What are objects used for?
a group or set of variables and function.
What are object properties?
variables but they are apart of the object (boundaries)
Describe object literal notation.
opening brace and then properties then value then closing
How do you remove a property from an object?
delete operator
What are the two ways to get or update the value of a property?
dot notation or bracket notation
What are arrays used for?
store lists of values
Describe array literal notation.
[ value1, value2, value3]
How are arrays different from “plain” objects?
arrays are object with index numbers as the properties
What number represents the first index of an array?
0
What is the length property of an array?
count how many items is in the array.
How do you calculate the last index of an array?
array[array.length -1]
What is a function in JavaScript?
a block of rerunnable code that have a specific instructions on how to do certain task.
Describe the parts of a function definition.
function functionName(parameters separating by comma) { code block return }
Describe the parts of a function call.
functionName(arguements)
When comparing them side-by-side, what are the differences between a function call and a function definition?
function definition have the syntax function leading and the code block. whereas the calling only have the function names and its specific arguements.
What is the difference between a parameter and an argument?
parameters is to setup the function. arguement is the value for that certain case being use by the function.
parameter is for defining
argument is for calling
Why are function parameters useful?
It let you access data and automate things that you other wise cannot do.
What two effects does a return statement have on the behavior of a function?
it gives the function a result value.
and it stops the function from continuing once a return is run.
Why do we log things to the console?
To check the output of the code
What is a method?
a function which is a properies of an object.
How is a method different from any other function
it is a part of an object
How do you remove the last element from an array?
array.pop