Javascript Flashcards
What is the purpose of variables?
to use later
How do you declare a variable
var
How do you initialize (assign a value to) a variable?
var name = value
What character are allowed in a variable name?
letter, $, underscore _, number but not start with a number
What does it mean to say that variable names are case sensitive?
different variables if casing is different
What is the purpose of a string?
arguments
What is the purpose of a number?
numerical value
What is the purpose of a boolean?
true/false, data type
How do you update the value of a variable?
var name = value, no need to add var in front of var name
What is the difference between null and undefined?
null needs to be purposefully assigned made to be empty to be filled later
Why is it a good habit to include “labels” when you log values to the browser console?
easier to debug later
Give five examples of Javascript primitives?
string, number, boolean, null, undefined
Give five examples of Javascript primitives?
string, number, boolean, null, undefined
What data type is returned by an arithmetic operation?
numerical
What is string concatenation?
tie two strings together
What purpose(s) does the + plus operator server in JavaScript
concatenation, add +
What data type if returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
addition assignment, take result as new value
What are objects used for?
grouping multiple properties with values that are related to each other
What are objects properties?
variables glued to objects
Describe object literal notation.
arraysof properties to their values
How do you remove a property from an object?
delete object.property
What are the two ways to get or update the value of a property?
property.nameOfvalue, or property[‘nameOfvalue’], and delete property.nameOfvalue
What are arrays used for?
lists of the same purpose/context rather than related
Describe array literal notation.
square brackets separated in commas
How are arrays different from “plain” objects?
arrays have number indexes, objects have key/named values/properties (arrays also have an order, objects and their properties do not)
What number represents the first index of an array?
0
What is the length property of an array?
.length, first to last # of the list/array (or total count)
How do you calculate the last index of an array?
using length property (.length) -1 , because indexes start at 0 , length count starts at 1
Describe the parts of a function definition.
function function name , return
Describe the parts of a function call.
function name ()
When comparing them side-by-side, what are the differences between a function call and a function definition?
functions definition contain the action, function calls are invoking the function to be used
What is the difference between a parameter and an argument?
parameters are present function definitions, arguments are present during function calls
Why do we log things to the console?
debugging
what is a method?
a way to do things
What is the purpose of an if statement?
gives a requirement in order to achieve the result
Is else required in order to use an if statement?
no
What is the purpose of a loop?
repeatedly run a block of code until a defined condition is met
What is the purpose of a condition expression in a loop?
When to continue, and when to end
What does “interation” mean in the context of loops?
in the beginning, once
Besides a return statement, which exits entire function block, which keyword exits a loop before its condition expression evaluates to false?
break statement
What does ++ increment operator do?
adds one (push 1)
How do you interate through the keys of an object?
for…in loops
What event is fired when a user places their cursor in a form control?
focus