Week 3 Review Flashcards
Review Week 3 Readings and FCC
Loop over an array using “for”.
for (let i = 0; i < myArray.length; i++) { // Use myArray[i] to access each array element one by one }
Loop over an array using for each
myArray.forEach(myElement => { // Use myElement to access each array element one by one });
Loop through an array using for-of
for (const myElement of myArray) { // Use myElement to access each array element one by one }
Remove the 2nd, 3rd, and 4th element using splice
myArray.splice(1,3)
Splice syntax
Splice method with index of first element and second parameter is how many elements to remove
TF Strings are objects with methods and properties
True
TF A javascript string is immutable
True
Convert a string to lower case
myString.toLowerCase()
Convert a string to upper case
myString.toUpperCase
TF You can use == to compare two strings
False use ===
Access each letter of a string
for (let i = 0; i < myString.length; i++) { Console.log(myString[1]); }
Access each letter of a string using for of
const name = "Sarah"; for (const letter of name) { console.log(letter); }
Turn a string into an array
const name = "Sarah"; const nameArray = Array.from(name);
What does
const song = “Honky Tonk Women”;
console.log(song.indexOf(“Onk”));
Return
-1 because string not found because case mismatch
Break a string apart into array
myString = ’Jan, 12’
myString.split(“,“)
Find index of ‘r’ in string “Forrest”
myString = “Forrest”;
myString.indexOf(“r”);
Object Orientated Programming or OOP is a programming ________________
paradigm
A JavaScript class is defined with the ________ keyword.
class
What method is called during object creation
constructor()
The keyword that represents the object on which a method was called
this
Objects are created from a class with the _______ operator
new
Javascripts OOP model is based on ___________
prototypes
When trying to access a property that does not exist in an object, JavaScript then tries to find the property by in the ________ ________
prototype chain
The method used to create a link between objects through prototypes
Object.create()