Skip to content

Instantly share code, notes, and snippets.

@badsyntax
Created September 10, 2010 13:49
Show Gist options
  • Save badsyntax/573655 to your computer and use it in GitHub Desktop.
Save badsyntax/573655 to your computer and use it in GitHub Desktop.
String.prototype.toInt = function(){
var neg = /^-/.test( this );
return ( neg ? -1 : +1 ) * ( parseInt( this.replace(/[\W]+/g, '') ) || 0 );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment