How to remove the weight of JavaScript
This article will explain in detail how to weigh JavaScript for you. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Deweighting
1. The ultimate piece
Array.from (new Set) / / [1 new Set ([1, 2, 3, 3, 4))] / / [1, 2, 3, 3, 4, and 4].
Set is a new data type from ES6 that defines non-repeating arrays.
Array.from converts an array of classes to an array
... Is an extension operator that converts values in set into strings
two。 The beginning
Array.prototype.distinct = function () {var arr = this, result = [], I, j, len = arr.length; for (I = 0; I < len; itemized +) {for (j = I + 1; j < len; juniper +) {if (arr [I] = arr [j]) {j = + + I;}} result.push (arr [I]);} return result;} [1pr 2, 3pr 3, Jing 4].
Take the stored value of the new array and cycle through the comparison of the two array values
This is the end of the article on "how to re-JavaScript". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.