String.prototype.bin = function () {
return parseInt(this, 2);
};
Number.prototype.bin = function () {
var sign = (this < 0 ? "-" : "");
var result = Math.abs(this).toString(2);
while(result.length < 32) {
result = "0" + result;
}
return sign + result;
}
//result
console.log("110".bin())
//00000000000000000000000000000110
console.log(6..bin())
//6