Skip to content

Commit deb8b78

Browse files
committed
example of Well-formed JSON.stringify.
1 parent 9e03c99 commit deb8b78

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

_data/stage3.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,21 @@
308308
tests:
309309
- https://github.com/tc39/test262/pull/1787
310310
specification: https://tc39.github.io/proposal-well-formed-stringify/
311+
example: >
312+
// Non-BMP characters still serialize to surrogate pairs.
313+
JSON.stringify('𝌆')
314+
// → '"𝌆"'
315+
316+
JSON.stringify('\uD834\uDF06')
317+
// → '"𝌆"'
318+
319+
// Unpaired surrogate code units will serialize to escape sequences.
320+
JSON.stringify('\uDF06\uD834')
321+
// → '"\\udf06\\ud834"'
322+
323+
JSON.stringify('\uDEAD')
324+
// → '"\\udead"'
325+
311326
resources:
312327
- https://tc39.github.io/proposal-well-formed-stringify/
313328

0 commit comments

Comments
 (0)