It takes the type/form in which the normalized string is to be returned finally as the only parameter. There are 4 normal forms:
“NFC” – Canonical Decomposition that followed by the Canonical Composition.
“NFD” – Canonical Decomposition
“NFKC” – It refers to the Compatibility Decomposition that is followed by Canonical Composition.
“NFKD” – Compatibility Decomposition
The value returned by this method is the Unicode Normalization form of the given string.
You may have heard of Unicode. It is nothing but simply assigning a unique numeric value to each character called the code-point. Similarly, we can relate this to ASCII in electronic communication standards. It involves assigning a unique value to each character.
When we call the normalize() method without passing parameter, it uses the “NFC” form. Also, there’s a possible error thrown named RangeError. This arises when the parameter passes is not one of the above forms.
var str = "Normalization"; var nfc = str.normalize("NFC"); // Normalization var nfd = str.normalize("NFD"); // Normalization var nfkc = str.normalize("NFKC"); // Normalization var nfkc = str.normalize("NFKD"); // Normalization