Skip to content
Open
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
15 changes: 10 additions & 5 deletions assignments/this.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
/* The for principles of "this";
* in your own words. explain the four principle for the "this" keyword below.
*
* 1.
* 2.
* 3.
* 4.
*
* 1. Window/Global Object Binding - In the gobal scope "this" will be the window/console object.
* 2. Implicit Binding - When a function is called using a dot(.) the object before dot is "This".
* 3. New Binding - If a constructor function is used "This" refers to specific instance of created object that it returns.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good answers Eustace 👍

* 4. Explicit Binding - If javascript call \ method used then "This" is explicitly defined.
* write out a code example of each explanation above
*/

// Principle 1

// code example for Window Binding
function book(title) {
console.log(this);
return title;
}

book("the secret");

// Principle 2

Expand Down