Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

what is normalize in javascript

// The normalize() method returns the Unicode Normalization Form of the string.

const name1 = 'u0041u006du00e9u006cu0069u0065';
const name2 = 'u0041u006du0065u0301u006cu0069u0065';

console.log(`${name1}, ${name2}`);
// expected output: "Amélie, Amélie"
console.log(name1 === name2);
// expected output: false
console.log(name1.length === name2.length);
// expected output: false

const name1NFC = name1.normalize('NFC');
const name2NFC = name2.normalize('NFC');

console.log(`${name1NFC}, ${name2NFC}`);
// expected output: "Amélie, Amélie"
console.log(name1NFC === name2NFC);
// expected output: true
console.log(name1NFC.length === name2NFC.length);
// expected output: true
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #normalize #javascript
ADD COMMENT
Topic
Name
2+8 =