function myFunc(){
console.log(myFunc.message);
}
myFunc.message = \"Hi John\";
myFunc();
Executing the above results in -
Answer:
According to MDN, definition of function is:
In JavaScript, functions are first-class objects, because they can have properties and methods just like any other object. What distinguishes them from other objects is that functions can be called. In brief, they are Function objects.
So here by doing myFunc.message
you are adding an additional property to myFunc
function( or object) and then it is accessible inside function like other objects.