How to make an array from a string by newline in JavaScript?

前端 未结 2 1936
执念已碎
执念已碎 2020-12-30 19:38

I\'ve got this:

var quoted_text = window.getSelection;

For example:

Accepting the Terms of Service

The Stack Exchange Netw

2条回答
  •  旧巷少年郎
    2020-12-30 20:39

    Use split()

    Fore example

    str = "abc\ndef";
    console.log(str.split("\n"));
    

    will print out

    ["abc", "def"] 
    

提交回复
热议问题