Skip to content

Instantly share code, notes, and snippets.

@geforester
Created August 29, 2017 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geforester/87661a67ce4f51390de765e2d4311326 to your computer and use it in GitHub Desktop.
Save geforester/87661a67ce4f51390de765e2d4311326 to your computer and use it in GitHub Desktop.
// Удаление элемента из массива.
// String value: значение, которое необходимо найти и удалить.
// return: массив без удаленного элемента; false в противном случае.
Array.prototype.remove = function(value) {
var idx = this.indexOf(value);
if (idx != -1) {
// Второй параметр - число элементов, которые необходимо удалить
return this.splice(idx, 1);
}
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment