The substring methods extracts the characters between the first param(start) and second param(last), but does not include the last.
Start : the first position from where the extraction begins. The first position is at index 0.
end : it up to (but not including) where the extraction ends.
To extract the first 10 character from a string, the syntax will be
let str = "abcdefghijkl" let tenChar = str.substring(0,10) console.log(tenChar) //abcdefghij <- FIRST 10 CHARACTER FROM THE STRING
The extraction of the character starts with the position 0 (the position is index 0 ) and ends with 10 (the position is index 9).
substring()will swap the two arguments. Example (5,1) will be swap to (1,5).
substring()method will not bring as changes to the original string.
This article is how to sort an array of string with non-ASCII characters. Using localeCompare() we can sort mixed array with non-ascii characters.