Skip to content

I completed the this.js section of the project and now I'm going to w… #749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<firstName-lastName>`.
* [ ] Implement the project on your newly created `<firstName-lastName>` 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 `<firstName-lastName>`.
* [x] Implement the project on your newly created `<firstName-lastName>` branch, committing changes regularly.
* [ ] Push commits: git push origin `<firstName-lastName>`.

**Follow these steps for completing your project.**

* [ ] Submit a Pull-Request to merge <firstName-lastName> 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 <firstName-lastName> 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

Expand Down
66 changes: 53 additions & 13 deletions assignments/this.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,66 @@
/* 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

// Principle 2

// 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
introduce.call(singer, talents);