Javascript Flashcards
Javascript primitives and variables
What is the purpose of variables?
Store values
Javascript primitives and variables
How do you declare variable?
specify the type, leave at least one space, then the name for the variable and end the line with a semicolon ( ; ).
Javascript primitives and variables
How do you initialize (assign a value to) a variable?
const, let, var
Javascript primitives and variables
What characters are allowed in variable names?
period, underscore, $,#,@
Javascript primitives and variables
What does it mean to say that variable names are “case sensitive”?
Example
let apple
let Apple
they are different
Javascript primitives and variables
what is the purpose of a string?
It represents text
Javascript primitives and variables
What is the purpose of a number?
It represents number values
Javascript primitives and variables
What is the purpose of a boolean?
true/false statements
Javascript primitives and variables
What does the = operator mean in Javascript?
Compare values and calculation?
Javascript primitives and variables
How do you update the value of a variable?
var totalPets = 10000; totalPets = 23;
Javascript primitives and variables
What is the difference between null and undefined?
Null: intentional absence of the value
Undefined: The value doesn’t exist
Javascript primitives and variables
Why is it a good habit to include “labels” when you log values to the browser console?
Debugging, or know where you are at
Javascript primitives and variables
Give five examples of JavaScript primitives.
string, number, undefined, null, boolean
Javascript operators and expressions
What data type is returned by an arithmetic operation?
number
Javascript operators and expressions
What is string concatenation?
Adding strings with + operator
Javascript operators and expressions
What purpose(s) does the + plus operators serve in Javascript
Concatenation
arithmetic
Javascript operators and expressions
What data type is returned by comparing two values (, ===, etc?)
boolean
What are objects used for?
To shape a model, multiple types of data, or functions
What are object properties?
variables that are attached to the object
Describe object literal notation
{ key: value}
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 or bracket notation
What are arrays used for?
Store the data?
What are arrays used for?
Store the data?
Describe array literal notation
var name = [];
How are arrays different from “plain” objects?
single variables
What number represents the first index of an array?
0
What is the length property of an array?
number of items in an array
How do you calculate the last index of an array?
arr.length -1
function defined name convertMinutesToseconds with one parameter (minutes) and then opening curlybrace for the code block
expression 60 *minutes being assgined to variable seconds
return of the function value is being assigned to
What is a function in JavaScript?
Describe the parts of function definition.
Describe the parts of a function call?
When comparing them side-by-side, what are the difference between a fucntion call and a function
What is the difference between a parameter and argument?
parameter: placehodler
arguments: giving values
Why are function parameters useful?
Takes arguments to the function
Why do we log things to the console?
Check if it’s working
What is a method?
function that is property of the object
How is a method different from any other function?
Connected to any other object
How do you remove the last element from an array?
.pop
Round number down?
.floor
How do you generate a random number?
Math.random * array.length
How do you delete an element from an array?
splice
How do you append an element to an array?
push
How do you break a string up into an array?
.split
space, comma,
Do string methods change the original string?
How would you check if you weren’t sure?
Strings are unchangeable
console log the original string value and console lot the
Roughly how many string methods are there according to the MDN Web docs?
Around 50ish.
Is the return value of a function or method useful in every situation?
No, console.log , they aren’t needed.
Roughly how many array methods are there according to the MDN Web docs?
A lot aournd 50ish
What three-letter acronym should you slways include in your Google search about a Javascript method or CSS property?
MDN
Give 6 examples of comparison operators
=, ==, ===, <=, >=, !=