You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description: 'Returns the Unicode Normalization Form of a string.'
4
+
Subjects:
5
+
- 'Code Foundations'
6
+
- 'Computer Science'
7
+
Tags:
8
+
- 'JavaScript'
9
+
- 'Methods'
10
+
- 'String'
11
+
- 'Unicode'
12
+
CatalogContent:
13
+
- 'introduction-to-javascript'
14
+
- 'paths/front-end-engineer-career-path'
15
+
---
16
+
17
+
The **`.normalize()`** method in JavaScript returns the Unicode Normalization Form of a string. This is especially useful when comparing strings that may look identical but are composed of different Unicode code points.
18
+
19
+
## Syntax
20
+
21
+
```pseudo
22
+
string.normalize([form])
23
+
```
24
+
25
+
**Parameters:**
26
+
27
+
-`form` (Optional): A string specifying the Unicode normalization form. Valid values are:
28
+
-`'NFC'` (Default): Canonical Composition
29
+
-`'NFD'`: Canonical Decomposition
30
+
-`'NFKC'`: Compatibility Composition
31
+
-`'NFKD'`: Compatibility Decomposition
32
+
33
+
**Return value:**
34
+
35
+
A new string in the specified normalization form.
36
+
37
+
## Example: Comparing Unicode Representations
38
+
39
+
In this example, two visually identical strings have different Unicode encodings, and `.normalize()` is used to make them comparable:
40
+
41
+
```js
42
+
constword1='\u00e9'; // é as single character
43
+
constword2='\u0065\u0301'; // e + ́ (combining acute)
0 commit comments