JavaScript converts a string to a list of character encodings
- 2020-05-17 04:46:46
- OfStack
This example demonstrates how JavaScript converts a string into a list of character encodings. Share with you for your reference. The details are as follows:
JavaScript converts a string to a list of character encodings, such as foo 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 is helpful to you in javascript programming.