Take the following code:
let myObject = {};
myObject.someFunction = function(){return 'sample function';};
myObject.someFunction.someOtherFunction = function(){return 'this somehow works';};
I can then run both myObject.someFunction()
and myObject.someFunction.someOtherFunction()
just fine.
What is the logic and implications behind this working? How is a function able to have methods?