javaScript Flashcards
What is the purpose of variables?
Storing data and going back to use it
How do you declare a variable?
Using keyword “var”
How do you initialize (assign a value to) a variable?
=;
What characters are allowed in variable names?
Must begin with a letter, _underscore, or $ dollar-sign
can’t start with number
What does it mean to say that variable names are “case sensitive”?
Uppercase and lowercases matter
Must be consistent with captializations
What is the purpose of a string?
String data types are in quotes
Used to add new content into a page
What is the purpose of a number?
Used to mathematical tasks
What is the purpose of a boolean?
To declare it true or false
What does the = operator mean in JavaScript?
Assigning a value to the variable
How do you update the value of a variable?
Assigning different values to the variable
What is the difference between null and undefined?
Null - represents a reference point for nonexistent or invalid objects (space for value) (purposeful)
Undefined - how JS tells you nothing (not purposeful) not purposed result of a declared object
Why is it a good habit to include “labels” when you log values to the browser console?
Describes the description of the value, in order to debug
ex:
var debug = letsgo;
console.log(“so that you can debug:”, debug);
Give five examples of JavaScript primitives.
Boolean, numbers, undefined, string, null
What data type is returned by an arithmetic operation?
Numbers
What is string concatenation?
It’s adding 2 strings together
Strings are textual content
What purpose(s) does the + plus operator serve in JavaScript?
Addition of numbers
And also concatenation of strings
What data type is returned by comparing two values (, ===, etc)?
Boolean
What does the += “plus-equals” operator do?
The Addition-assignment operator adds value to the variable.
What are objects used for?
To hold its properties and functions in order to create a model
What are object properties?
Properties are tells us specific characteristics of the object that relate to each other
Properties Variables glued to objects
Describe object literal notation.
Declares the variable equating to curly braces
How do you remove a property from an object?
Use “delete” operator
What are the two ways to get or update the value of a property?
Using the dot notation to the object
Using square bracket notation with the property inside
What are arrays used for?
Container for lists
Special type of objects.
Describe array literal notation.
Square objects
How are arrays different from “plain” objects?
They hold a related set of key/value, but the key for each value is its numerical indexes (not alpha numeric)
In an array, order of properties are important
-Square brackets instead of curly braces
What number represents the first index of an array?
0 index
What is the length property of an array?
Holds the number of items in the array
How do you calculate the last index of an array?
.length - 1;
What is a function in JavaScript?
A JavaScript function is a block of code designed to perform a particular task
Describe the parts of a function definition.
Function keyword, function name, parentheses, curly braces for definition block
Describe the parts of a function call.
Function keyword, function name, parentheses to pass arguments
When comparing them side-by-side, what are the differences between a function call and a function definition?
function call - function keyword, name of function and arguments, doesn’t have curly braces after