[JS] Find key from value


/ Published in: JavaScript
Save to your folder(s)

/*Coded by Alessio Delmonti - www.tecnocrazia.com*/


Copy this code and paste it in your HTML
  1. function getKeyStr(j, ar){ //recupera la chiave partendo da il valore di un array
  2. var i;
  3. for(i in ar){
  4. if (j == ar[i]){
  5. return i;
  6. }
  7. else{continue;}
  8. }
  9. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.