How to get the js variable name. For example, var item1; gets the variable name I instead of the variable value 1.

how to get the js variable name. For example, var item1; gets the variable name I instead of the variable value 1.

Oct.24,2021

for(var k in window) {
    if(window[k] == 1) {
        console.log(':'+ k);
    }
}

then try this

let timerObj = new Map()
for (let i =0 ;i < 5; iPP) {
  timerObj.set(`timer_${i}`, ()=>{console.log('')}) 
}
for(let param of timerObj) {
     console.log(param)
}
Menu