Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // < метод set аналог в python >
- function set(max, min=[]){
- function uniqFun(val) {return val.filter((element, index, array) => array.indexOf(element) === index);}
- var uniq = {
- set1: function() {this.set1 = uniqFun(max)},
- set2: function() {this.set2 = uniqFun(min)},
- minus: function() {
- const namesArr = this.set1;
- const namesToDeleteArr = this.set2;
- const namesToDeleteSet = new Set(namesToDeleteArr);
- return namesArr.filter((name) => {
- return !namesToDeleteSet.has(name);
- });
- },
- plus: function(){
- const set1 = this.set1;
- const set2 = this.set2;
- const set3 = set1.concat(set2);
- return uniqFun(set3)
- }
- }
- uniq.set1(); uniq.set2();
- return uniq
- }
- // < / метод set аналог в python >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement