Why “this” inside of a function's returning object window

后端 未结 3 1516
萌比男神i
萌比男神i 2021-01-18 18:14

there is two type of scope in javascript named function scope global scope

now i am executing this code

function abc()
{
alert(this)         


        
3条回答
  •  囚心锁ツ
    2021-01-18 18:32

    The this keyword refers to the object the function belongs to, or the window object if the function belongs to no object.

    Reference

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this

提交回复
热议问题