JavaScript's split() method automatically adds the \r character at the end of the string
P粉738248522
P粉738248522 2023-09-03 12:15:15
0
1
511

I'm trying to create an array with the fetched data and create a new collection with it, but the resulting string has \r at the end:

export const WordSetFn = async () =>{ let wordSet; await fetch(wordsSet).then((resp) => resp.text() ).then((resp) =>{ const wordSetArray = resp.split("\n") wordSet = new Set(wordSetArray) }) return {wordSet}; } // word set would look like this: {"above\r",...}

And the txt file I'm getting the data from is a bunch of words, each word is on the next line, like this:

aback abase abate abbey abbot Abhor Abide abled Abode abort ...

Now why is \r added after every word? What does \r mean?

P粉738248522
P粉738248522

reply all (1)
P粉066725148

\ris a carriage return character,\nis a line feed character,\r\nis a carriage return character plus a line feed character.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!