From c71694c129737096d8d8a4e0e0d88122f1acfddc Mon Sep 17 00:00:00 2001 From: KhushalGupta305 <43728353+KhushalGupta305@users.noreply.github.com> Date: Mon, 1 Oct 2018 12:12:53 +0530 Subject: [PATCH] Update Readme.md Added new javascript question . --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 4de35de..53cd034 100644 --- a/README.md +++ b/README.md @@ -3373,8 +3373,28 @@ console.log(mul(2)(3)(4)(5)(6)); Answer: 1) 720 +### 7. What will the code below output to the console ? + +var myObject = { + foo: "bar", + func: function() { + var self = this; + console.log("outer func: this.foo = " + this.foo); + console.log("outer func: self.foo = " + self.foo); + (function() { + console.log("inner func: this.foo = " + this.foo); + console.log("inner func: self.foo = " + self.foo); + }()); + } +}; +myObject.func(); +Answer: The above code will output the following to the console: +outer func: this.foo = bar +outer func: self.foo = bar +inner func: this.foo = undefined +inner func: self.foo = bar ## Contributing