00 Votes

JavaScript: How to reset array's protoype in JavaScript ?

Question by Wordpress-developer | 2021-08-13 at 14:59

Array.prototype.min = function() {
  return Math.min.apply(Math,this);
};

How to reset Array.prototype ?

ReplyPositiveNegative
11 Vote

First of all, I would never override any of the default function.

If you cannot prevent this, for example because of an external script does the override, you can do the following:

Use a variable to store the old function in it before the script changes it. Then you can restore the function with setting Array.prototype.min back to the variable afterwards.
2021-08-13 at 16:16

ReplyPositive Negative
Reply

Related Topics

JavaScript: Sort Array

Question | 1 Answer

JavaScript: Get Array Length

Question | 1 Answer

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.