Answers for "js string to charcode array"

4

string to char array in javascript

const string = 'hi there';

const usingSplit = string.split('');              
const usingSpread = [...string];
const usingArrayFrom = Array.from(string);
const usingObjectAssign = Object.assign([], string);

// Result
// [ 'h', 'i', ' ', 't', 'h', 'e', 'r', 'e' ]
Posted by: Guest on October-25-2020
0

convert string to char array javascript

const string = 'word';

// Option 1
string.split('');

// Option 2
[...string];

// Option 3
Array.from(string);

// Option 4
Object.assign([], string);

// Result:
// ['w', 'o', 'r', 'd']
Posted by: Guest on May-02-2020
0

js string to charcode array

let input = "words".split("");
let output = [];
input.forEach(letter => {
	output.push(letter.charCodeAt(0))
});
console.log(output) //[119, 111, 114, 100, 115]
Posted by: Guest on July-21-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language