javascript Flashcards
What is the purpose of variables?
to store data for the future
How do you declare a variable?
use a variable keyword to declare the variable then a variable name
“var poopy”
How do you initialize (assign a value to) a variable?
use a =
What characters are allowed in variable names?
letters, underscores, $, numbers can be used but NOT in the front
Numbered variable names are CRINGE
What does it mean to say that variable names are “case sensitive”?
Score =/= score
What is the purpose of a string?
way to hold a sequence of characters - preserve text without freaking js out
What is the purpose of a number?
calculations, MATHS
What is the purpose of a boolean?
use it to make a choice
What does the = operator mean in JavaScript?
to assign variables things
How do you update the value of a variable?
var name then assign it to another variable, no keyword
What is the difference between null and undefined?
null - intentional absence of a value - it can be defined
undefined - bad - empty that comes from JS. it says “theres nothing here” - means you fucked up
Why is it a good habit to include “labels” when you log values to the browser console?
otherwise you don’t know what the console log is for
Give five examples of JavaScript primitives
string, number, boolean, undefined, null
What data type is returned by an arithmetic operation?
number
What is string concatenation?
taking any type of values. that get added to a string, and it all becomes a string.
What purpose(s) does the + plus operator serve in JavaScript?
math and concatenate
What data type is returned by comparing two values (<, >, ===, etc)?
boolean
What does the += “plus-equals” operator do?
they dbz fusion into gotenks
What are objects used for?
group together variables/properties
what if i need info on more than 1 dog???
What are object properties?
key + value inside the object
the word & the definition in the dictionary
Describe object literal notation.
an array of key:value pairs with a comma inbetween, except for the last
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?
brackets or dot for get, same for update
What are arrays used for?
good for lists of stuff at any length
the order is either EXTREMELY important, or doesn’t matter
Describe array literal notation.
brackets baybee with any data type inside
How are arrays different from “plain” objects?
all arrays have a length property, even []
What number represents the first index of an array?
0, big fat zero
What is the length property of an array?
how long the array is
How do you calculate the last index of an array?
array.length minus 1
What is a function in JavaScript?
a set of stuff that performs a task
Describe the parts of a function definition.
inputs outputs rules, (), {}, function name, parameters, keywords, etc etc etc
var const let for while do
Describe the parts of a function call.
arguments parameters function name
When comparing them side-by-side, what are the differences between a function call and a function definition?
define makes the function call runs it, calls have no {}
What is the difference between a parameter and an argument?
arguments are values provided when function is called
parameters are placeholder names for when function is defined