Completed Lambda School Precourse

March 09, 2019

Most of it was review but the last couple of sections on classes and prototypes took some extra time to get reacquainted with the concepts.

Control Flow is the order in which various parts of a program are executed (usually in response to conditional statements).

Logical Operators are used to combine two equality expressions (<, <=, >, >=, ===, !==) and ask if either of them are true (||), both of them are true (&&), or neither of them is true (!).

The return statement is the only way for data to escape a function. Nothing other than what is returned can be accessed from outside of the function.

.unshift([item]) will put a new item in the front of an array.

.shift() will remove the first item in the array.

.map([callback])will apply the callback function to each item in the array and return the new array (with returned values)

When to use bracket notation over dot notation for objects? If youre using a variable as the object key to access the value.

The delete keyword can be used to remove object properties from an object, but best practice is to just set the value to undefined.

for..in loops can be used to iterate over key:value pairs in objects. EG.

for(let key in obj) {
  console.log(obj[key];
}

Classes in JS are really just functions that will return an object. These type of functions are known as class constructors and the objects are known as classes.

When the new keyword is placed in front of a function call, JS will treat the function as a class constructor.

We use classes to create objects that have the same style of data and methods.

Creating functions are expensive (on computer memory) and each time we create a new class object with methods, we are recreating those methods in memory. Each class has a common repository for methods, known as the prototype. By setting methods on the prototype of the class (rather than on the class itself), every instance of the class can use the same function while substantially reducing the memory used.


Also signed up for Watch & Code premium tonight. Looking forward to starting on that tomorrow!

← back to all posts