A rookie question, javascript's question about the selected elements of slice, has been figured out before, but recently I forgot it when I reviewed it. I can't remember what's going on!

/ / divide the following strings into the array according to the rules.
"Li Ming: 60; Xiaohua: 76; Xiaowen: 90; Xiaomei: 85; Zhang Hua: 68; Li Yang: 74; Tiantian: 90; Wang Qiang: 69; Xiaohe: 87; Liu Yang: 72"

var scoreinfos=":60; :76; :90; :85;:68;:74;:90;:69;:87;:72";
var myarr=scoreinfos.split(";");
 for(var i=0;i<myarr.length;iPP)
 
{
    document.write(myarr[i]+"<br/>");

/ / the display is as follows:
Li Ming: 60
Xiaohua: 76
essay: 90
Xiaomei: 85
Zhang Hua: 68
Li Yang: 74
Tiantian: 90
Wang Qiang: 69
Xiaohe: 87
Liu Yang: 72

/ / the array should be displayed as follows:

myarr=[:60,:76,:90,:85,:68,:74,:90,:69,:87,:72]()

/ / slice selected element

document.write(myarr[i].slice(3)+"<br/>");

/ / display the following
60
76
90
85
68
90
69
69
72
/ / but according to the definition of slice, the third place will be selected, and the latter will be selected, and should be displayed like this.
60
floret: 76
essay: 90
Xiaomei: 85
Zhang Hua: 68
Li Yang: 74
every day: 90 < br

Mar.09,2021

.
the array looks like this after you split.
this is how he divides var arr = ['Li Ming: 60', 'floret: 59']
for loop does not mean

arr[0].slice(3) => 60
arr[1].slice(3) => 59

var scoreinfos=":60; :76; :90; :85;:68;:74;:90;:69;:87;:72";
var myarr=scoreinfos.split(";");
The result of

is an array of strings

[":60", " :76", " :90", " :85", ":68", ":74", ":90", ":69", ":87", ":72"]

myarr [I] traverses the string
original string in the array. Slice (3) the result is the answer you expect
throw link MDN split


The

split () method is used to split a string into an array of strings.
it is cut in ";", so the array you get is ["Li Ming: 60", "Xiaohua: 76", "Xiaowen: 90", "Xiaomei: 85", "Zhang Hua: 68", "Li Yang: 74", "Tiantian: 90", "Wang Qiang: 69", "Xiaohe: 87", "Liu Yang: 72"].
if you want what you want, it should be

var myarr=scoreinfos.split(";");
document.write(myarr.slice(3)+"<br/>");

you don't need to traverse the array, you get the elements in myarr

.
myarr[0].slice(3) => 60
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bdffb2-30a08.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bdffb2-30a08.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?