Traditional Function referring to the global objects/window in browser
Hayk, I was studying the this keyword video in the JavaScript course, but I was wondering when you said the traditional function was referring to windows in the browser, did you mean only when it is called outside of the function, like in this example below, where I wrote const fn = myObj.showWindow; fn(); ? This is the example ai gave me and ai said that showWindow is a traditional function inside the object, but when called as fn(), this refers to the global object (window in browser), not myObj anymore. Ai also said the only difference between a traditional function and a traditional method is the the traditional function is written using a colon, like the colon after showWindow below. Ai also said the difference between traditional function and method is that traditional function use the colon (:), it can be assigned to a variable before being called out of the function, while the traditional method is written without a colon, and it is called directly as object key, like it is myobj.function name. Is this correct about what the ai said and is that what you was saying when you said the this keyword in the traditional function refers to the global object/window in your browser? const myObj = { name: 'Amber', showWindow: function() { console.log(this); // Will reference window if called as a standalone function } }; const fn = myObj.showWindow; // Assign method to variable fn(); // 'this' now refers to window (global object in browser)