MISCELLANEOUS ENHANCEMENTS
ES2019 also introduces a handful of tweaks to existing tooling:
Array.prototype.sort()
is stable, meaning that equivalent objects will not be reordered in the output.- Lone UTF-16 surrogate characters cannot be encoded in UTF-8, which causes problems with
JSON.stringify()
. Rather than return unpaired surrogate code points as single UTF-16 code units, they are now represented with JSON escape sequences. - Previously, both U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR were valid in JSON strings but invalid in ECMAScript strings. ES2019 introduces compatibility between ECMAScript strings and JSON strings.
- Formerly, browser vendors had lots of room to specify what was returned from
Function.prototype.toString()
. ES2019 requires that this method return the function's source code whenever possible, otherwise{ [native code] }
.