Return to Snippet

Revision: 12407
at March 12, 2009 19:58 by Sephr


Initial Code
String.prototype.toCharCodes = function toCharCodes() {
  return Array.prototype.map.call(this, function(str) {
    return str.charCodeAt(0)
  })
};

String.fromCharCodes = function fromCharCodes(charCodes) {
  return String.fromCharCode.apply(this, charCodes)
};

Initial URL

                                

Initial Description
*Requires JavaScript 1.6 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`.

Initial Title
string.toCharCodes & String.fromCharCodes [JS 1.6]

Initial Tags

                                

Initial Language
JavaScript