Last active
          August 29, 2015 14:07 
        
      - 
      
 - 
        
Save rohozhnikoff/a43cfed27c41e4e68cdc to your computer and use it in GitHub Desktop.  
    simle and fast finder in js-array
  
        
  
    
      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 findInArray(array, callback) { | |
| for (var i = 0, element = array[i], length = array.length; i < length; i++) { | |
| if (callback.apply(callback, [element, i, array])) return element; | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Bit of an issue with this implementation. The
elementis only assigned once when the loop initializes. Try assigning element as follows: