Can anyone please let me know why the function declarations are hidden in JavaScript object?
const obj: any = {}
obj.normal = 'normal prop'
obj.func = function(){}
console.log(obj)
This only returns:
{
"normal": "normal prop"
}
However, we can access obj.func
obviously. But my question is why the func
property is hidden while normal
property is not.
Ah, I just noticed that this behavior is being seen only in TypeScript. Here's the
CodePudding user response:
This seems to be an issue with typeScript playground as it is working correctly in https://www.mycompiler.io/
using same code