Why in JavaScript is a function considered both a constructor and an object?

前端 未结 8 1217
半阙折子戏
半阙折子戏 2021-01-03 02:23

I have been doing a lot of research on this lately, but have yet to get a really good solid answer. I read somewhere that a new Function() object is created when the JavaScr

8条回答
  •  攒了一身酷
    2021-01-03 02:43

    Only when you instantiate with the new keyword does the function act as a constructor.

    The result is an object that can use the "this" keyword to access member properties. The this keyword in the method does not make any sense when the function is used any other way.

提交回复
热议问题