Answers for "split array in js"

21

javascript split

// bad example https://stackoverflow.com/questions/6484670/how-do-i-split-a-string-into-an-array-of-characters/38901550#38901550

var arr = foo.split(''); 
console.log(arr); // ["s", "o", "m", "e", "s", "t", "r", "i", "n", "g"]
Posted by: Guest on May-01-2020
3

string to array javascript

// If you want to split on a specific character in a string:
const stringToSplit = '01-02-2020';
console.log(stringToSplit.split('-')); 
// ["01", "02", "2020"]

// If you want to split every character:
const stringToSplit = '01-02-2020';
console.log(Array.from(stringToSplit));
// ["0", "1", "-", "0", "2", "-", "2", "0", "2", "0"]
Posted by: Guest on October-14-2020
3

split javascript

var str = "12,15,16,78,59";
var res = str.split(",");
console.log(res[0]); // result: 12
console.log(res[2]); // result: 16
Posted by: Guest on December-02-2020
4

split array javascript

// Returns new array from exising one
arr.slice(start, end);
Posted by: Guest on March-16-2020
1

HOW TO SPLIT AN ARRAY JAVASCRIPT

array.splice(index, number, item1, ....., itemN)
Posted by: Guest on November-17-2019
1

javascript split

var arr = ['hey', 'nay', 'wey'];
var let = arr.split(' ');
console.log(let);
Posted by: Guest on September-20-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language