Search code examples
javascriptobjectcompiler-constructionintermediate-language

Javascript object representation format


In compiler IR representation, we know that function type can be represented using Cartesian Product.

For example:

function my_func(a, b) { return c; }

the function type can be denoted as: (int × double)->int

(note that here I assume that all types are known)

So, if I declare an object in Javascript like

var obj = {"name":"haha", "id":123};

Is there any formal representation to represent obj which is object type in Javascript ?

Thank you.


Solution

  • Javascript is unityped language. That is, there is no separate int, string, double, byte data types. All it has is var.

    All objects, take the literal form of [object Object] when they are converted to strings.

    There is no javascript debuggers AFAIK that debugs to such a depth to know all these things.