Oddity in Javascript map object
I'm using the javascript map object and its not working as expected. I searched the forum for any issues with the map object, but found nothing. The relevant javascript documentation is here. I created a form with javascript at the Page Level. The javascript uses an iterable literal for initialization:
this.myMapIterable = [ [ "002", { "code": "002", "rate": 0.0165 } ], ];
this.myMap = new Map(this.myMapIterable);
I shortened myMapIterable to one entry, but in the original there are over 50 entries. The length of the iterable does not present itself as an issue. Given the above code one would expect that getting an entry, using the following code, would produce the associated object:
this.myMap.get("002");
The above, should according to the Javascript documentation, produce the object:
{ "code": "002", "rate": 0.0165 }
Unfortunately, it doesn't. What I get is undefined!? I been battling this issue for the past day. Playing around in the Javascript debugger, I have found that the Acrobat implementation of Javascript makes a distinction between how a string is quoted. I'm not sure why since the Javascript documents points out in the note just above here, that there is no difference between a single quoted string or a double quoted string. If I change the code to the following:
this.myMapIterable = [ [ '002', { 'code': '002', 'rate': 0.0165 } ], ];
this.myMap = new Map(this.myMapIterable);
and then also do:
this.myMap.get('002');
then, finally I get:
{ 'code': '002', 'rate': 0.0165 }
However, if I change the above myMap.get() to:
this.myMap.get("002");
then, I get undefined!?
This makes no sense to me given the Javascript documentation. Further, I tried both versions in NodeJS and both work as expected, regardless of which quotes were used for either myMapIterable and those used in the myMap.get(). Mixing and matching in NodeJS just works and it seems to be in line with the Javascript documentation, IMHO.
Does anyone have a reason for this behavior in Acrobat DC and do you concur on my reading of the Javascript documentation and how things work in NodeJS?
