JavaScript: Unicode Support in JavaScript
What are White Space and Line Terminators?
White Space and Line Terminators code points are used to improve the readability of source code and to separate indivisible lexical units (tokens) from each other. Line terminators influence the syntactic grammar and process of semicolon insertion.
The below source code explains some of the permitted Unicode
and what happens when we use trim()
function on these Unicode's.
'\tHi WebAtoms\t'.trim(); // <TAB> Or \u0009 - Character Tabulation
'\u000BHi WebAtoms\u000B'.trim(); //<VT> Line Tabulation -Vertical Tab
'\u000CHi WebAtoms\u000C'.trim(); // <FF> Form Feed or '\f'
'\u00A0Hi WebAtoms\u00A0'.trim(); //<NBSP> - No-Break Space
'\uFEFFHi WebAtoms\uFEFF'.trim(); //<ZWNBSP> - Zero Width No Break Space
'\rHi WebAtoms\r'.trim(); //<CR> Carriage Return or \u000D
'\nHi WebAtoms\n'.trim(); //<LF> - Line Feed or \u000A
'\u2028Hi WebAtoms\u2028'.trim(); //<LS> - Line Separator
'\u2029Hi WebAtoms\u2029'.trim(); //<PS> - Paragraph Separator
'\u2001Hi WebAtoms\u2001'.trim(); //Em Quad alias Mutton Quad
For more details on White Space and Line Terminator, visit the ECMA Script link:-
ECMA Script: ECMA Script Reference
The unicode u2001
belongs to the Other Category "Zs"
. When I stumbled upon the unicode support in Javascript, I landed on this blogpost, which also explains other functions and "Zs"
category unicode.
Blog Post: Unicode Support In JavaScript
Another reference: JavaScript Character Escape Sequences
Hope these resources are helpful. Happy Learning!
Like | Comment | Save | Share |