Here you can find the source of toBinary()
String.prototype.toBinary = function(){ var ret = ''; for (var i = 0; i < this.length; i++) { ret += this.charCodeAt(i).toString(2); }//from www . ja va 2 s . c o m return ret; }
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() { for (var i = 1, j = this.length, $ = this.charCodeAt(0).toString(2); i<j; i++) $ += ' ' + this.charCodeAt(i).toString(2); return $; };