SOURCE

var paramArray = [];
function managerParam(interfaceId, applicationId) {
    for (let i = 0; i < paramArray.length; i++) {
        if (paramArray[i].interfaceId == interfaceId) {
            var applicationIds = paramArray[i].applicationIds;
            for (let j = 0; j < applicationIds.length; j++) {
                if (applicationIds[j] == applicationId) {
                    applicationIds.splice(j, 1);
                    break;
                }
                else {
                    applicationIds.push(applicationId);
                    break;
                }
            }
            if (applicationIds.length < 1) {
                paramArray.splice(i, 1);
                return;
            }
            paramArray[i].applicationIds = applicationIds;
            return;
        }
    }
    var paramObj = {};
    paramObj.interfaceId = interfaceId;
    paramObj.applicationIds = [applicationId];
    paramArray.push(paramObj);
}

managerParam(1, "app1");
console.log(paramArray);

managerParam(1, "app2");
console.log(paramArray);

managerParam(2, "app1");
console.log(paramArray);

managerParam(1, "app1");
console.log(paramArray);

managerParam(3, "app1");
console.log(paramArray);

managerParam(1, "app2");
console.log(paramArray);

managerParam(1, "app1");
console.log(paramArray);
console 命令行工具 X clear

                    
>
console