Adding prototype to Math.__proto__ breaks Plotly

On my application, I added a prototype to Math to round decimals. After that, (minified, version 1.40.0, for whatever reason couldn’t make npm package and require work) started failing when trying to plot a valid OHLC graph giving the error message below:

Uncaught TypeError: e._subplots[f].sort is not a function

For whatever reason, adding that prototype to Math breaks Plotly as a whole.

How to reproduce:

  1. Add a prototype to Math as example below:
    Math.proto.roundDecimal = function (value, decimals){
    return Number(Math.round(value+‘e’+decimals)+‘e-’+decimals);
  2. Plot anything (add it to before Plotly call)
  3. ???
  4. Open Console
  5. “Uncaught TypeError: e._subplots[f].sort is not a function”

While I know that one should not change core libraries/classes prototypes, but this kind of abstraction helps a lot when you need proper decimal rounding and Math doesn’t bother to have it. Also, I don’t understand how one additional prototype that doesn’t overwrite any other on Math can break a whole API.