JavaScript String isWellFormed()
Examples
let text = "Hello world!";
let result = text.isWellFormed();
Try it Yourself »
let text = "Hello World \uD800";
let result = text.isWellFormed();
Try it Yourself »
Description
The isWellFormed()
method returns true
if a string is well formed.
Otherwise it returns false
.
A string is well formed if does not contain lone surrogates.
Lone Surrogates
A Lone surrogate is a Unicode surrogate code that is not a part of a valid surrogate pair, used to represent characters in UTF-16 encoding.
Syntax
string.isWellFormed()
Parameters
NONE |
Return Value
Type | Description |
Boolean | true if the string is well formed,
otherwise false . |
Browser Support
isWellFormed()
is an ES2024 feature.
JavaScript 2024 is fully supported in all modern browsers since March 2024:
Chrome 117 | Edge 117 | Firefox 119 | Safari 17.4 | Opera 103 |
Sep 2023 | Sep 2023 | Oct 2023 | Okt 2024 | May 2023 |