JavaScript this refers to window instead of object inside function

this has nothing to do with scope. It is determined by context.

greeting() calls the function with no context, so this is the default object (window in a browser).

Leave a Comment