OOP guys Beware!! A function in Javascript is not what you think

When the below snippet was run, I was shocked and I realized that I should be very careful with JavaScript.

function test(){
console.log(“Hello”)
}

var t = test;
t.id=”1";
t();
console.log(t.id);
console.log(typeof(t))

Output:
Hello
1
function

Then i did the research and understood what I have missed while learning JavaScript.

Every function in JavaScript is a Function object.

A function without a return statement will return a default value.
In the case of a constructor called with the new keyword, the default value is the value of its this parameter. For all other functions, the default return value is undefined.

Suffering from Knowledge Quest

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store