1: The split function splits the string according to a certain character and stores the split result in the string array
function SplitUsersInformation(users) {
var usersArray = users.split(';');
return usersArray;
}
2: The substr function cuts the target string
currentStr = currentStr .substr(0, currentStr.length - 2);
3: The push method adds a record to Array
var totalUsers = new Array();
function PushItem(name, departmemt) {
var currentUser = new Object ();
currentUser.UserName = name;
currentUser.Department = departmemt;
totalUsers.push(currentUser);
}
4: pop method from Array Pop the top record from the 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() ;
//There will be user1 left in totalUsers, because user2 is at the top of the stack and will be popped
5: The splice method deletes one or more specified records from the Array
var totalUsers = new Array();
totalUsers.push (...);
function SpliceItem(name) {
for (var i = 0; i < totalUsers.length; i ) {
if (totalUsers[i].UserName == name) {
totalUsers. splice(i, 1)
}
}
}