Created
January 18, 2017 14:40
-
-
Save sokoljr/257dec2ebf5a5258c5d93df06e11d3f5 to your computer and use it in GitHub Desktop.
seen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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