Here you can find the source of toBinary()
// Method to encode a string as a series of bits // 'Seth'.toBinary(); returns '1010011 1100101 1110100 1101000' String.prototype.toBinary = function() { for (var i = 1, j = this.length, $ = this.charCodeAt(0).toString(2); i<j; i++) $ += ' ' + this.charCodeAt(i).toString(2); return $;//from ww w .ja v a 2 s .c o m };
String.prototype.toBin = function() { var st,i,j,d; var arr = []; var len = this.length; for (i = len; i>0; i--) { d = this.charCodeAt(i-1); for (j = 0; j < 8; j++) { arr[arr.length] = d%2; d = Math.floor(d/2); ...
String.prototype.toBinary = function(){ var ret = ''; for (var i = 0; i < this.length; i++) { ret += this.charCodeAt(i).toString(2); return ret;