From 60553f4ecab2d8b128af4e6a6881e198ad6ccb23 Mon Sep 17 00:00:00 2001 From: Allan Tito Date: Wed, 9 Aug 2017 20:05:01 -0400 Subject: [PATCH 1/2] AdvancedJS mini commit 9UG --- app.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index eba22ae..1a9c8b3 100644 --- a/app.js +++ b/app.js @@ -1,14 +1,19 @@ /* The four rules for 'this'; * in your own words. explain the four rules for the "this" keyword below. -* 1. -* 2. -* 3. -* 4. +* 1. When you have 'this' inside a function in a global scope; its value will be the window object +* 2. On functions called by a preceding dot; the object before the dot is 'this' +* 3. 'this' points to an instance of an object when uusing a constructor function +* 4. 'this' can be explicitly defined when using the call or apply method * write out a code example of each explanation above */ // First Rule - +function greet(name) { + console.log(`Hello ${name}`); + console.log(, this); +} +console.log(, this); +conosle.log('greet', greet('Allan')); // Second Rule // Third Rule From 47ed8c109ed8ea81fc72a9053b991a28d2743c7b Mon Sep 17 00:00:00 2001 From: Allan Tito Date: Thu, 10 Aug 2017 18:49:30 -0400 Subject: [PATCH 2/2] AdvancedJS mini commit 10UG --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index 1a9c8b3..18b75e9 100644 --- a/app.js +++ b/app.js @@ -10,7 +10,7 @@ // First Rule function greet(name) { console.log(`Hello ${name}`); - console.log(, this); + console.log(, this); } console.log(, this); conosle.log('greet', greet('Allan'));