const names = ["code","codepadding"] const key = "codepadding"; var have = names.includes(key) // return true / false if(have){ // do something }