If you need to split string to array by space in javascript then i will show you how to split string into array by comma or space in javascript. javascript has split() that will help to explode string into array.
Javascript split() function is used to split a string into array of substrings, and returns the new array.
I will give you simple example for this bellow example, i created simple string with comma. then i will use split function to create an array using split function in javascript. so let's see bellow simple example:
Example:
<!DOCTYPE html>
<html>
<head>
<title>How to split string to array by comma using javascript? - HDTuto.com</title>
</head>
<body>
<script type="text/javascript">
var myString = "A,B,C,C,D,E,F,G,H";
console.log(myString.split(','));
</script>
</body>
</html>
I hope it can help you....
Do you like below Tutorials ?
- Angular Json Pipe Example | Json Pipe in Angular 9/8/7
- Angular Slice Pipe Example | Slice Pipe in Angular 9/8/7
- Angular Uppercase Pipe Example | Uppercase Pipe in Angular 9/8/7
- Angular LowerCase Pipe Example | LowerCase Pipe in Angular 9/8/7
- Angular Titlecase Pipe Example | Titlecase Pipe in Angular 9/8/7
- Angular KeyValue Pipe Example | KeyValue Pipe in Angular 9/8/7
- Call Method from One Component to Another Component in Angular
- Angular Push Object into Array Example