JavaScript String isWellFormed() Method Last Updated : 17 Jul, 2023 Comments Improve Suggest changes Like Article Like Report JavaScript String.isWellFormed() method is used to check if the string contains a lone surrogate or not. A lone surrogate is a string that contains Unicode characters in the range 0xD800–0xDBFF and 0xDC00–0xDFFF. It returns trues if the lone surrogate is not present. If the string is not well-formed it will give an error if we use the encodeURI() method on it. Syntax: isWellFormed()Parameters: It does not take any parameter Return Value: A boolean, true if no lone surrogate is present, and false if the lone surrogate is present. Example 1: This example uses the isWellFormed() method on strings. JavaScript const str1 = "ab\uD800"; const str2 = "new\uD800"; const str3 = "hello"; console.log(str1.isWellFormed()); console.log(str2.isWellFormed()); console.log(str3.isWellFormed()); Output: falsefalsetrueExample 2: This example will perform the encodeURI function only on well-formed strings. JavaScript const badFormed = "ab\uD800"; const wellFormed = "hello"; function checkFormation(str) { if(str.isWellFormed()){ console.log(encodeURI(str)) } } checkFormation(wellFormed); checkFormation(badFormed); Output: helloSupported Browsers: ChromeEdgeOperaSafariWe have a complete list of Javascript string methods, to check those please go through this Javascript String reference article. Comment More infoAdvertise with us Next Article JavaScript String isWellFormed() Method S shobhit_sharma Follow Improve Article Tags : JavaScript Web Technologies Similar Reads Java String isEmpty() Method with Example In Java, the String isEmpty() method checks if a string is empty (length is zero). This method returns true if the string is empty and false otherwise. It is useful for validating strings in our applications.In this article, we will learn how to use the isEmpty() method in Java along with examples t 3 min read String Handling with Apache Commons' StringUtils Class in Java The Apache Commons Lang library is a popular third-party library for working with Strings in Java, and the StringUtils class is a key part of this library. StringUtils is a utility class that provides a wide range of String manipulation methods that are not available in the standard Java String clas 9 min read Charset isSupported() method in Java with Examples The isSupported() method is a built-in method of the java.nio.charset checks if a given charset is supported or not. Syntax: public final boolean isSupported() Parameters: The function accepts a single mandatory parameter charset Name which specifies the canonical name or the alias name which is to 2 min read Java String contains() Method with Example The String.contains() method is used to search for a sequence of characters within a string. In this article, we will learn how to effectively use the string contains functionality in Java.Example:In this example, we check if a specific substring is present in the given string.Java// Java Program to 3 min read Check if a String Contains only Alphabets in Java In Java, to check if a string contains only alphabets, we have to verify each character to make sure it falls within the range of valid alphabetic characters. There are various ways to check this in Java, depending on requirements.Example: The most common and straightforward approach to validate if 4 min read Like