How do javascript functions have properties in them?

后端 未结 4 1136
萌比男神i
萌比男神i 2021-01-21 09:08
function myFunc(){
    console.log(myFunc.message);
}
myFunc.message = \"Hi John\";

myFunc();

Executing the above results in -

Answer:         


        
4条回答
  •  花落未央
    2021-01-21 09:30

    How does the above work? Is function in javascript internally an object?

    Yes

    function example() {};
    
    console.log(example instanceof Object);

提交回复
热议问题