Skip to content

Instantly share code, notes, and snippets.

@bogutski
Last active June 22, 2018 18:57
Show Gist options
  • Save bogutski/62180e47e4f39006a1cbc97fb9a95b23 to your computer and use it in GitHub Desktop.
Save bogutski/62180e47e4f39006a1cbc97fb9a95b23 to your computer and use it in GitHub Desktop.
Notes
=== Сравнение массивов ==============================================================
let mas1 = ["some1", "some2", "some3", "some4"],
mas2 = ["some1", "some5", "some3"];
Array.prototype.diff = Array.prototype.diff || function(a2) {
return this.filter(i => a2.indexOf(i) < 0);
};
console.log(mas1.diff(mas2));
=== Перестановка элементов в массиве=================================================
let mas1 = ["some1", "some2", "some3", "some4"];
Array.prototype.move = function(from, to) {
this.splice(to, 0, this.splice(from, 1)[0]);
};
mas1.move(2,3);
console.log(mas1);
=== Максимальное значение в массиве ================================================
Math.max.apply(null, array)
Math.max(...arr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment