JavaScript String isWellFormed()
Examples
let text = "Hello world!";
let result = text.isWellFormed();
Try it Yourself »let result = text.isWellFormed();
let text = "Hello World \uD800";
let result = text.isWellFormed();
Try it Yourself »let result = text.isWellFormed();
Description
TheisWellFormed() method returnstrueif a string is well formed.
Otherwise it returnsfalse.
A string is well formed if does not containlone surrogates.
Lone Surrogates
ALone 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,otherwisefalse. |
Browser Support
isWellFormed() is a JavaScrip 2024 feature.
ES 2024 is supported in all modern browsers sinceMarch 2024:
| Chrome 117 | Edge 117 | Firefox 119 | Safari 17.4 | Opera 103 |
| Sep 2023 | Sep 2023 | Oct 2023 | Okt 2024 | May 2023 |

