Skip to content

Instantly share code, notes, and snippets.

@sokoljr
Created January 18, 2017 14:40
Show Gist options
  • Save sokoljr/257dec2ebf5a5258c5d93df06e11d3f5 to your computer and use it in GitHub Desktop.
Save sokoljr/257dec2ebf5a5258c5d93df06e11d3f5 to your computer and use it in GitHub Desktop.
seen
function seen( prop_val, arr, prop_name=null ) {
if( prop_name == null ) {
for ( var i = 0; i < arr.length; i++ ) {
if ( prop_val == arr[i] ) {
return i;
}
}
}
else {
for( var i = 0; i < arr.length; i++) {
if( prop_val == arr[i][prop_name] ) {
return i;
}
}
}
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment