Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript this Keyword Value inside a Simple Function</title> </head> <body> <script> function Person(nickname, country) { this.nickname = nickname; this.country = country; this.getInfo = function() { // Outer function context (Person object) return function() { // Inner function context (Global object 'Window') document.write(this.constructor.name); // Window document.write("<p>Hi, I'm " + this.nickname + " from " + this.country + "</p>"); }; } } var p = new Person('Rick', 'Argentina'); var printInfo = p.getInfo(); printInfo(); // Hi, I'm undefined from undefined </script> </body> </html>