Skip to content

Instantly share code, notes, and snippets.

@aweary
Created January 28, 2015 23:58
Show Gist options
  • Save aweary/e0b47f8b7bcb7f8e1e51 to your computer and use it in GitHub Desktop.
Save aweary/e0b47f8b7bcb7f8e1e51 to your computer and use it in GitHub Desktop.
Add a toBinary() method to all numbers
Number.prototype.toBinary = function(){
return parseInt(this.toString(2));
};
// > (55).toBinary()
// > 110111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment