Array prototype methods


SUBMITTED BY: djwisnia55

DATE: Sept. 29, 2016, 6:52 p.m.

FORMAT: JavaScript

SIZE: 312 Bytes

HITS: 1022

  1. Array.prototype.has = function(value) {
  2. return this.indexOf(value) !== -1;
  3. };
  4. Array.prototype.clear = function()
  5. {
  6. this.length = 0;
  7. return this;
  8. };
  9. Array.prototype.remove = function(value) {
  10. var index = this.indexOf(value);
  11. if(index > -1) {
  12. this.splice(index, 1);
  13. }
  14. return this;
  15. };

comments powered by Disqus