How does js execute object functions in turn? the number of functions is uncertain.

as follows, functions need to be added frequently and executed sequentially. Each function renders a different class, after the result is obtained, so it needs to be executed in turn, and some parameters need to be passed in

let testcase = {

case1:(x) =>{
    console.log("case11-"+x);
},
case2:() =>{
    console.log("case22");
    return false;
},
case3:() =>{
    console.log("case33");
}
.....

}

Mar.24,2021

is best written as an array, and object property traversal is unordered. If you want to write as an object, first make sure that you can use sort to sort out the order you want (naming convention or attribute convention), and then you can traverse and execute it in turn.


on the same floor, it is best to use arrays to organize your structure to ensure that traversing is orderly.

Menu