Languages
[Edit]
EN

JavaScript - convert textarea lines into array

0 points
Created by:
Jan-Alfaro
681

In this article, we would like to show you how to convert textarea lines into an array using JavaScript.

Quick solution:

 

Preview

Edit
JavaScript - convert textarea lines into array
JavaScript - convert textarea lines into array

Practical example

Edit

In this example, we get handle to textarea by id using document.querySelector() method. Then we take its value and we split it into an array by new line character (\n) using split() method.

 

See also

Edit
  1. JavaScript - get textarea field value

References

Edit
  1. String.prototype.split() - JavaScript | MDN

Alternative titles

  1. JavaScript - convert textarea value into array
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join