diff --git a/README.md b/README.md index ed9a277bc..7c9746af2 100644 --- a/README.md +++ b/README.md @@ -6,18 +6,18 @@ This challenge focuses on using the `this` keyword as well as getting comfortabl **Follow these steps to set up and work on your project:** -* [ ] Create a forked copy of this project. -* [ ] Add your project manager as collaborator on Github. -* [ ] Clone your OWN version of the repository (Not Lambda's by mistake!). -* [ ] Create a new branch: git checkout -b ``. -* [ ] Implement the project on your newly created `` branch, committing changes regularly. +* [x] Create a forked copy of this project. +* [x] Add your project manager as collaborator on Github. +* [x] Clone your OWN version of the repository (Not Lambda's by mistake!). +* [x] Create a new branch: git checkout -b ``. +* [x] Implement the project on your newly created `` branch, committing changes regularly. * [ ] Push commits: git push origin ``. **Follow these steps for completing your project.** -* [ ] Submit a Pull-Request to merge Branch into master (student's Repo). **Please don't merge your own pull request** -* [ ] Add your project manager as a reviewer on the pull-request -* [ ] Your project manager will count the project as complete by merging the branch back into master. +* [x] Submit a Pull-Request to merge Branch into master (student's Repo). **Please don't merge your own pull request** +* [x] Add your project manager as a reviewer on the pull-request +* [x] Your project manager will count the project as complete by merging the branch back into master. ## Assignment Set Up diff --git a/assignments/this.js b/assignments/this.js index 969bbeeba..effc1045f 100644 --- a/assignments/this.js +++ b/assignments/this.js @@ -1,15 +1,25 @@ -/* The for principles of "this"; -* in your own words. explain the four principle for the "this" keyword below. -* -* 1. -* 2. -* 3. -* 4. -* -* write out a code example of each explanation above -*/ + // The for principles of "this"; +// in your own words. explain the four principle for the "this" keyword below. + +// // 1. Window Global object binding +// When you are inside of the global scope, the value of this is the entire window/console Object. It's a broad area that will need some specification. We can specify what we are implitmenting or pointignt o by using something referred to as "Implicit Binding" +// 2. Implicit Binding +// Implicit binding is pointing to something directly inside of the global scope. We can specify what that is exactly by using "this." for example we can say "this.greeing" "this.age" "this.animal" +// // 3. New Binding +// New binding is when we use the new keyword to call a fucntion that creates an object for us. An example is +// fucntion CordialPerson(greeter) and then using... +// Const jasmine = new CordialPerson('tyler') +// jasmine.speak (); + + +// 4. Explicit Binding +// Explicit binding is when we call someting explicitly with a new constext using .call and .apply +// an example of this is jasmine.speak.call(tyler);tyler.speak.apply(jasmine); + +// write out a code example of each explanation above // Principle 1 +console.log(this) // code example for Window Binding @@ -17,10 +27,40 @@ // code example for Implicit Binding +const person = { + name: "Jasmine", + age: "26", + location: "San Francisco", + code: function() { + return `${this.name} loves to ${this.code}`; + }} +console.log(person.code()); // Principle 3 -// code example for New Binding +//New Binding Example + +function CordialPerson(greeter) { + this.greeting = "Hola, Como estas"; + this.greeter = greeter; + this.speak = function() { + console.log( `${this.greeting} ${this.greeter} `); + } +} + +const jasmine = new CordialPerson("Jennifer Lopez"); + +jasmine.speak(); + +// Exlicit binding + +const singer = { + 'name':'Beyonce', + 'age':38 +} +const talents = ['singing','dancing', 'acting']; -// Principle 4 +function introduce() { + console.log(`My name is: ${this.name} my talents are, ${talents}`); +} -// code example for Explicit Binding \ No newline at end of file +introduce.call(singer, talents); \ No newline at end of file