From e1e98ed363e4e0d38d0206b730fcd5be3c31b479 Mon Sep 17 00:00:00 2001 From: Matt Huntington Date: Sun, 21 Aug 2016 18:09:48 -0400 Subject: [PATCH] this keyword --- javascript.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/javascript.md b/javascript.md index 6c9888b..8176555 100644 --- a/javascript.md +++ b/javascript.md @@ -188,6 +188,19 @@ var myObj = { myObj.functionProperty(); ``` +When invoking methods, you can reference other properties of the object with the keyword `this` + +```javascript +var myObj = { + color: 'blue', + functionProperty: function(){ + console.log(this.color); + } +} + +myObj.functionProperty(); //logs 'blue' +``` + Can be passed as parameters to other functions ```javascript