I agree with "hemnath mouli" code should be like as he wrote:
<script type="text/javascript">
keys = {HT2787UK: "9618", HT2787Z1UK: "9619", HT2787Z3UK: "9621", HT2787Z2UK: "9620"};
function getIndexOf(obj,value){
var count = 0;
for (var i in obj){
if(obj[i] == value.toString()){
return "index[" + count + "]:" + obj[i] + " = " + i;
//return what you want
}
count ++;
}
}
</script>
Then U got the values
<script type="text/javascript">
alert(getIndexOf(keys,9621));
</script>
Could you please send a piece of code to retrieve the values @ClementNerma even I agree with you this is not the more efficient way.
I just do not want to "downvote" the question.
Or if you want to convert your Object to an Array:
<script type="text/javascript">
keys = {HT2787UK: "9618", HT2787Z1UK: "9619", HT2787Z3UK: "9621", HT2787Z2UK: "9620"};
function obj2Array(obj){
k = [];
for (var i in obj){
k.push(obj[i]);
}
return k;
}
</script>
<script type="text/javascript">
arr = obj2Array(keys);
alert (arr[2]);
</script>
@abu abu
.indexOflooks only at numeric indices. Your Array has been populated with non-numeric properties, which will be ignored. So the question would be why an Array is being used this way in the first place.Object.entries(skus_colorcode).find(a => a[1] == "9620")[0].