Method One: This is my method, I hope you correct me ...
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Randomly extract 5 different values from a length of 100 array</title></Head><Body> <Script> vararr= NewArray ( -); varflag_a= NewArray ( -); /*this is a feature. itself is to set a flag property for each element of the array, but it does not work. So just create an array of the same size Boolean type*/ for (varI= 0; I<arr.length; I++) {Arr[i]= "This is the first"+I+"a"; Flag_a[i]= false; } for (varI= 0; I< 5; i) { varR=Math.floor (Math.random ()* -); if(!Flag_a[r]) {document.write (i+1+":"+Arr[r]+"<br/>"); FLAG_A[R]= true; I++;/*I think it's very creative to put i++ in this place. (*^__^*) hehe ...*/ } } </Script></Body></HTML>
Method Two: This method with the above is similar to the wonderful, is what others think, for everyone to reference ...
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Randomly extract 5 different values from an array of length 100 02</title></Head><Body> <Script> vararr= NewArray ( -); for (varI= 0; I<arr.length; I++) {Arr[i]= "This is the first"+I+"a"; } for (varI= 0; I< 5;) { varR=Math.floor (Math.random ()* -); if(Arr[r]!=NULL) {document.write (i+1+":"+Arr[r]+"<br/>"); ARR[R]= NULL;/*It is also good to use the set to NULL to determine whether it is used or not.*/I++; } } </Script></Body></HTML>
JS implementation randomly extracts 5 different values from an array of length 100