You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
functiongetStringValue(name,fullExpression){// From the JavaScript docs:// Property names must be strings. This means that non-string objects cannot be used// as keys in an object. Any non-string object, including a number, is typecasted// into a string via the toString method.//// So, to ensure that we are checking the same `name` that JavaScript would use,// we cast it to a string, if possible.// Doing `name + ''` can cause a repl error if the result to `toString` is not a string,// this is, this will handle objects that misbehave.name=name+'';if(!isString(name)){throw$parseMinErr('iseccst','Cannot convert object to primitive value! '+'Expression: {0}',fullExpression);}returnname;}
What caught my attention is that executing this line name = name + ''; can have only one of these two effects:
either a string is assigned to the name variable, or
an exception (TypeError: Cannot convert object to primitive value) is thrown by the JS engine if name.toString is 'broken' (doesn't return a string, isn't a function, etc.).
It's even mentioned in the comment in this code. This means this check if (!isString(name)) never passes, so $parseMinErr('iseccst', ...) is never thrown.