string parse to array javascript code example
Example 1: javascript slice string from character
var input = 'john smith~123 Street~Apt 4~New York~NY~12345';
var fields = input.split('~');
var name = fields[0];
var street = fields[1];
Example 2: convert string to array js
function f() {
return Array.from(arguments);
}
f(1, 2, 3);
const s = new Set(["toto", "truc", "truc", "bidule"]);
Array.from(s);
const m = new Map([[1, 2], [2, 4], [4, 8]]);
Array.from(m);
const mapper = new Map([["1", "a"], ["2", "b"]]);
Array.from(mapper.values());
Array.from(mapper.keys());
Array.from("toto");
Array.from([1, 2, 3], x => x + x);
Array.from({length: 5}, (v, k) => k);