I\'m trying to override a built in parseFloat function in JavaScript.
How would I go about doing that?
You could override it or preferably extend it's implementation like this
parseFloat = (function(_super) {
return function() {
// Extend it to log the value for example that is passed
console.log(arguments[0]);
// Or override it by always subtracting 1 for example
arguments[0] = arguments[0] - 1;
return _super.apply(this, arguments);
};
})(parseFloat);
And call it as you would normally call it:
var result = parseFloat(1.345); // It should log the value 1.345 but get the value 0.345