1: The split function splits the string by a specific character and saves the split result to the string array.
Function splitusersinformation (users ){
VaRUsersarray = users. Split (';');
ReturnUsersarray;
}
2: The substr function is used to cut the target string.
Currentstr = currentstr. substr (0, Currentstr. Length-2);
3: The Push method adds a record to the array.
VaRTotalusers =NewArray ();
Function pushitem (name, invalid memt ){
VaRCurrentuser =NewObject ();
Currentuser. Username = Name;
Currentuser. Department = Alibaba memt;
Totalusers. Push (currentuser );
}
4: The pop method pops up the top record from the array stack.
VaR Totalusers = New Array ();
VaR User1 = New Object ();
User1.username = " Haha " ;
User1.department = " Hahahaha " ;
VaR User2 = New Object ();
User2.username = " Lolo " ;
User2.department = " Lolololo " ;
Totalusers. Push (user1 );
Totalusers. Push (user2 );
Totalusers. Pop ();
// User1 is left in totalusers, because user2 is displayed at the top of the stack.
5: The splice method deletes a specified record or multiple records from the array.
VaRTotalusers =NewArray ();
Totalusers. Push (...);
Function spliceitem (name ){
For(VaRI =0; I <totalusers. length; I ++ ){
If(Totalusers [I]. Username = Name ){
Totalusers. splice (I,1)
}
}
}
6: For details about how to operate array in JS, refer to this blog.
Http://hi.baidu.com/%B3%E8%C8%E8%B2%BB%BE%AA0521/blog/item/0cada15b302b20401038c237.html