// Longhand switch (data) { case 1: data1(); break; case 2: data2(); break; case 3: data(); break; // And so on... } // Shorthand var data = { 1: data1, 2: data2, 3: data }; const val = 1 data[val](); function data1() { console.log("data1"); } function data2() { console.log("data2"); } function data() { console.log("data"); }