On Thu, Mar 20, 2014 at 9:07 PM, Bryan White <[email protected]> wrote: > I have a v8 object that is used to lookup US 5 digit zip codes in a > C++structure. To implement this the object template has a named property > handler. > > This has worked well in other contexts but here I am having a problem. In > this case a zip code is always a 5 digit string. In JavaScript when I do > the lookup the named property handler is never called. > > I am guessing that v8 is seeing that the string looks like a number and is > doing something different. Possibly calling an indexed property handler. I > suppose I could implement that on this object but then I am concerned that > zip codes with leading zeros would be converted as octal strings. > > Is my guess at what is happening correct and how can I fix it? > > Caveat: It has been a while since I have felt the need to update v8. The > version that I am using is from spring 2012.
Your guess is correct and it's part of the ECMAScript spec: property lookups on array objects are treated as indices if the result of ToString(ToUint32(name)) == name. And yes, if |name| has a leading zero, it gets interpreted as an octal number. You could prefix the zip code with a non-digit (ugly) or use a method instead of a property handler. -- -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
