Home > front end >  Small white ask array to weight problems
Small white ask array to weight problems

Time:12-05

more than two to weight is not the same as the one above is to use j to and I than, and below than that using the I and j, where is the difference between the two  just learn less than a week js is the wound received

CodePudding user response:

There is no difference, it is a variable

CodePudding user response:

Variable I began from 0
The variable j starts
1Arr. Splice (I, 1)
Delete the array arr. Splice (j, 1) is not the same as the starting position of the

CodePudding user response:

Splice method two parameters, the first is the location of array index, the second parameter number;
Splice (0, 1); Is deleted from the position of the index of 0, 1 element;

CodePudding user response:

reference 3/f E time Mr Reply:
splice method two parameters, the first is the location of array index, the second parameter number;
Splice (0, 1); Is deleted from the position of the index of 0, 1 element;
at least two parameters

CodePudding user response:

Use written es7, than the good you understand
Var sz=,2,3,4,2,2,5 [1];
Var newsz=new Set (sz) [...];

The results of newsz is to heavy

CodePudding user response:

Search js filter

CodePudding user response:

Delete the array item again here in circular array, there will be a jump item, the first such as I=0, you find j=7 arrays are equal, then you delete the value of the array of 0, 0 array item no, paragraphs 1 to 0 data followed along behind a, I, is in order not to skip, if not, I will test in item 1 of the array is data 3, skip the data 2
The second delete similar
So generally don't delete in times when the array splice array of values

CodePudding user response:

Let newArr=Array. The from (new Set (arr))
The console. The log (newArr)

CodePudding user response:

Const STR=` sajlfjdiosajflewagnagl; Dhfoajhoidjsalf; Ewjhqoifdjksaljfoidhqagoieq `;
Let str2=STR. The split (')
Let str3=new Set (str2)
Let str4=str3 [...]
Let str5=str4. The join (). The split (', '). The join (")
The console. The log (str5)

This is my personal writing to weight method, also can see the Set and the use of Map collections

https://blog.csdn.net/JAN_LIGHT/article/details/107617796

CodePudding user response:

Array to reuse the set not sweet?

CodePudding user response:

This is a bit complicated, you take a look at this
<script>
Var arr=[1, 3, 1, 2, 3, 5, 2, 3, 4, 6].
//remove duplicate
Var arr1=[]
for(var i=0; iIf (arr1. IndexOf (arr) [I]==1) {
[I] arr1. Push (arr)

}
}
The console. The log (arr1);
</script>
  • Related