0

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.

shwu
  • 37
  • 4
  • Yes, that's an `[object Object]`. JavaScript is a unityped language. – elclanrs May 28 '14 at 06:07
  • @AmitJoki: Does it matter? – cookie monster May 28 '14 at 06:11
  • @cookiemonster, of course it does, as this *is* a good question and that comment is the answer, I suppose – Amit Joki May 28 '14 at 06:12
  • @AmitJoki: Nah, as long as the OP gets the info, it doesn't really make a difference where the info comes from. – cookie monster May 28 '14 at 06:14
  • 1
    @cookiemonster, that is where you're going wrong. It's not just about OP but about future readers who might have the same question, but they won't find an answer – Amit Joki May 28 '14 at 06:15
  • @AmitJoki: Future readers can read comments too, no? If you want to post an answer, you should go ahead. – cookie monster May 28 '14 at 06:17
  • @cookiemonster, I've been answering a lot, where elclanrs comments the same as my answer whilst I type. So, I don't want to be framed as the one who copies other's answer :) – Amit Joki May 28 '14 at 06:19
  • @AmitJoki: I understand, but you shouldn't let that stop you. If someone decides to post an answer as a comment, they have nothing to complain about when someone else posts a similar answer. – cookie monster May 28 '14 at 06:21
  • There has to be a duplicate somewhere, but I'm lazy, I don't want to elaborate, feel free to post a proper answer. – elclanrs May 28 '14 at 06:21
  • Thank you all. But may I ask that according to my example : var obj = {"name":"haha", "id":123}; How to represent this ? (I mean including all property types) – shwu May 28 '14 at 06:30

1 Answers1

0

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.

Amit Joki
  • 58,320
  • 7
  • 77
  • 95