Home >Web Front-end >JS Tutorial >JavaScript method to convert a string into a character encoding list_javascript skills
The example in this article describes how JavaScript converts a string into a character encoding list. Share it with everyone for your reference. The details are as follows:
JavaScript converts the string into a character encoding list, for example, foo is converted to [112,111,111]
Method 1: JavaScript 1.6
Array.map('foo', function(x) { return String.charCodeAt(x) }) // is [112,111,111]
Method 2: JavaScript 1.7
[ String.charCodeAt(x) for each ( x in 'foo' ) ] // is [112,111,111]
I hope this article will be helpful to everyone’s JavaScript programming design.