I need to search in an object. In a real project, there are many keys and objects that need to be checked. Which search method to use for better performance?
if(object.test1) console.log('true')
if(object.test2) console.log('true')
if(object.test3) console.log('true')
or
for (const key in object) {
if(key=='test1') console.log('true')
if(key=='test2') console.log('true')
if(key=='test3') console.log('true')
}
Is there a difference in execution speed? Or maybe there is another way better than these?