$.utils.code.toSource is unnecessarily conservative about quoting property names #469
Labels
core
Things related to the "core" part of the database
enhancement
Feature requests, major new features, etc.
server
Things related to the codecity server proper
$.utils.code.toSource({delete: 'foo'})
returns{'delete': "foo"}
, but the single quotes around "delete" are not needed because althoughdelete
is a reserved word it is being used here as a property rather than variable name.Similarly,
$.utils.code.toSource({4: 4})
returns{'4': 4}
when{4: 4}
is legal.The
$.utils.code.quote
function is doing this but it perhaps needs to be forked into different versions for different contexts. (Note that you can also sayobject.delete
but notobject.4
.)Whatever changes are made here should be back to
server/code.js
.Reference:
See https://262.ecma-international.org/5.1/#sec-11.1.5 (ES5.1) and/or https://tc39.es/ecma262/#sec-object-initializer (ES20xx) for the syntax of an ObjectInitializer; note that PropertyName (ES5.1) / LiteralPropertyName (ES20xx) can be any of IdentifierName, StringLiteral or NumericLiteral, and that IdentifierName is not the same as Identifier (which does exclude ReservedWord).
The text was updated successfully, but these errors were encountered: