Skip to content

Instantly share code, notes, and snippets.

@redgoose-dev
Last active October 17, 2017 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redgoose-dev/ce92a358d3d0de7c6ca592d869f68e73 to your computer and use it in GitHub Desktop.
Save redgoose-dev/ce92a358d3d0de7c6ca592d869f68e73 to your computer and use it in GitHub Desktop.
Object, Array utils
/**
* find index with key in array
* 배열속에 들어있는 객체의 값을찾는 함수
*
* @param {Array} array
* @param {String} key key name
* @param {String} search search value
* @return {Number}
*/
function findIndexWithKey(array=[], key='', search='')
{
for (let i=0; i<array.length; i++)
{
if (array[i][key] === search) return i;
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment