Skip to content

Instantly share code, notes, and snippets.

@nathansmith
Created June 15, 2011 15:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save nathansmith/1027395 to your computer and use it in GitHub Desktop.
Save nathansmith/1027395 to your computer and use it in GitHub Desktop.
Makes parseInt default to radix of 10.
// Protect against parseInt being used
// without radix, by defaulting to 10.
// Conditionally check value, in case
// future implementations of parseInt
// provide native base-10 by default.
(function(window) {
var _parseInt = window.parseInt;
if (_parseInt('09') === 0) {
window.parseInt = function(str, radix) {
return _parseInt(str, radix || 10);
};
}
})(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment