Skip to content
This repository has been archived by the owner on Sep 30, 2018. It is now read-only.

Commit

Permalink
editttt
Browse files Browse the repository at this point in the history
  • Loading branch information
codyloyd committed Nov 24, 2017
1 parent 65e4bf2 commit 04cf588
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 33 deletions.
22 changes: 0 additions & 22 deletions MoreJS/OOP.md

This file was deleted.

20 changes: 11 additions & 9 deletions MoreJS/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ The rest of the curriculum (after JS101) digs deeper and deeper into what all it

## Intermediate JS
1. Promises
1. API stuff
1. Testing (writing tests and TDD in general)
1. ES6 features (classes, arrows, destructuring, babel)
1. Webpack
2. API stuff
3. More DOM-stuff
4. Using Libraries (form validation, time-stuff, etc.)
5. Testing (writing tests and TDD in general)
6. ES6 features (classes, arrows, destructuring, babel)
7. Webpack
8. ORGANIZING JS:

## Advanced JS
1. Scope, Closures, Callbacks
1. Objects/this/ Call, Apply, Bind
1. OOP
1. Functional Programming
1. Scope, Closures, Callbacks
2. Objects/this/ Call, Apply, Bind
3. OOP
9. Functional Programming

Note that there will/should be plenty of projects dispersed throughout (ideally each major topic should have a project) but I have not created stubs for those... for now lets keep project ideas in the actual lesson file... we will break them out later.
Empty file removed MoreJS/objects-this.md
Empty file.
35 changes: 35 additions & 0 deletions MoreJS/organizing-js/factory-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,41 @@ Take a minute to look through this simplistic example and see if you can figure

What would happen here if we tried to call `jimmie.die()`? What if we tried to manipulate the health: `jimmie.health -= 1000`? Of course, those are things that we have NOT exposed publicly so we would get an error. This is a very good thing! Setting up objects like this makes it easier for us to use them because we've actually put some thought into how and when we are going to want to use the information. In this case, we have jimmie's health hiding as a private variable inside of the object which means we need to export a function if we want to manipulate it. In the long run this will make our code _much_ easier to reason about because all of the logic is encapsulated in an appropriate place.

### Inheritance with Factories

In the constructors lesson we looked fairly deeply into the concept of Prototypes and Inheritance, or giving our objects access to the methods and properties of another Object. There are a few easy ways to accomplish this while using Factories. Check this one out:

```javascript
const Person = (name) => {
const sayName = () => console.log(`my name is ${name}`)
return {sayName}
}

const Nerd = (name) => {
// simply create a person and pull out the sayName function!
const {sayName} = Person(name)
const doSomethingNerdy = () => console.log('nerd stuff')
return {sayName, doSomethingNerdy}
}

const jeff = Nerd('jeff')

jeff.sayName() //my name is jeff
jeff.doSomethingNerdy() // nerd stuff
```

This pattern is _great_ because it allows you to pick and choose which functions you want to include in your new object. If you want to go ahead and lump ALL of another object in, you can certainly do that as well with `Object.assign` (read the docs for that one [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)).

```javascript
const Nerd = (name) => {
const prototype = Person(name)
const doSomethingNerdy = () => console.log('nerd stuff')
return Object.assign({}, prototype, {doSomethingNerdy})
}
```

- Before moving on have a look at [this](https://medium.com/javascript-scene/3-different-kinds-of-prototypal-inheritance-es6-edition-32d777fa16c9) article. In the second half of the article the author goes into some things that we aren't really talking too much about here, but you'll be rewarded if you spend some time figuring out what he's talking about. Good stuff!

## The Module Pattern

> Quick sidenote: ES6 introduced a new feature in JavaScript called 'modules'. These are essentially a syntax for importing and exporting code between different JavaScript files. They're very powerful and we WILL be covering them later. They are _not_, however, what we're talking about here.
Expand Down
Empty file removed MoreJS/scope-closures.md
Empty file.
3 changes: 1 addition & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ This is a rough outline of the course. Note that it _does_ include the lessons
- ES6
- Scope/Closures/Objects/`this`
- Call, Apply and Bind
- OOP in JS => prototypal inheritance
- Functional Programming Concepts

### Other Stuff
Expand Down Expand Up @@ -106,4 +105,4 @@ _JS DOES NOT HAVE CLASSES_. This section is important.. crucial even.
- This is a great article for express: https://zellwk.com/blog/crud-express-mongodb/

### ...remainder is in progress

0 comments on commit 04cf588

Please sign in to comment.