I want something like this:
var onlineMobilesAnon=[];
onlineMobilesAnon["abc1"]="test";
console.log(onlineMobilesAnon.indexOf("test")); //Should return "abc1"
How can I achive this ?
I want something like this:
var onlineMobilesAnon=[];
onlineMobilesAnon["abc1"]="test";
console.log(onlineMobilesAnon.indexOf("test")); //Should return "abc1"
How can I achive this ?
This isn't exactly what you'd want, since it goes off of keys (Javascript Objects instead of Arrays, though an array is just a special javascript object anyway) and not index, but you could grab all the keys and check the value associated for the key and return that key with the following:
var onlineMobilesAnon = {}
onlineMobilesAnon["abc1"]="test"
var keys = Object.keys(onlineMobilesAnon);
for(var i = 0; i < keys; i++){
if(onlineMobilesAnon[keys[i]] == "test"){
console.log(keys[i])
}
}