JavaScript is case sensitive:
Keywords, variables, function names, and all identifiers must be consistent in upper and lower case (usually we write them in lower case), which is very different from the multi-style writing method of C# when I first learned.
For example: (Here we take the variables str and Str as examples)
The code copy is as follows:
var str='abc';
var Str='ABC';
alert(str);//Output abc
If str and Str are the same variable, then alert(str);, the output result should be ABC instead of abc as shown in the figure above. This just shows that JavaScript is case sensitive.
Unicode escape sequence
The appearance of Unicode character sets is to make up for the limitation that ASCII code can only represent 128 characters. If we want to display Chinese characters and Japanese in daily life, it is obvious that ASCII is impossible. So Unicode is a superset of ASCII and Latin-1. First of all, JavaScript programs are written with Unicode character sets, but they cannot be fully displayed or entered in some computer hardware and software. In order to solve this phenomenon, JavaScript defines a special sequence, which uses 6 ASCII characters to represent any 16-bit Unicode internal code. This special sequence is collectively called Unicode escape sequence, which is prefixed with /u and followed by 4 hexadecimal numbers.
for example:
The code copy is as follows:
var str='caf/u00e9';
var Str='café';
alert(Str+' '+str);// You can see that the display is the same effect.
alert (Str===str);//Output true
But we should note that Unicode allows multiple methods to encode the same character, and use the above example of é escape to illustrate:
é:
1. It can be represented by Unicode characters /u00E9
2. It can also be represented by e/u0301 (intonation character)
The code copy is as follows:
var str='caf/u00e9';
var Str='cafe/u0301';
alert(str+' '+Str); // As shown in the figure below, the results output by Str and str are the same
alert(Str===str); //The results are the same, but their binary encoding representations are completely different, so the output is false
Although the results displayed on the text editor are the same, their binary encoding representations are completely different, and the programming languages will eventually be converted into computer mechanical codes (binary encodings) of the local platform. Computers can only know the results by comparing binary encodings, so the final result of their comparison can only be false
So this is the best explanation for "Unicode allows multiple methods to encode the same character" because the Unicode standard defines a preferred encoding format for all characters to facilitate the conversion of text into Unicode escape sequences in a unified format for appropriate comparison
Take é as an example again:
Is it the same thing to compare the facé with the é in café?
Only by comparing the é in facé and café are converted to /u00E9 or both are converted to e/u0301 to compare the é in facé and café