string.toCharCodes & String.fromCharCodes [JS 1.8]


/ Published in: JavaScript
Save to your folder(s)

*Requires JavaScript 1.8 or higher*

Syntax:

`Array string.toCharCodes()` returns an array containing every one of `string`'s character codes, in order.

`String String.fromCharCodes(charCodes)` returns a string created from every character code in the array, `charCodes`.


Copy this code and paste it in your HTML
  1. String.prototype.toCharCodes = function toCharCodes()
  2. Array.prototype.map.call(this, function(str) str.charCodeAt(0));
  3. String.fromCharCodes = function fromCharCodes(charCodes)
  4. String.fromCharCode.apply(this, charCodes);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.