time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

repl.txt (1338B)


      1 
      2 {{alias}}( arr, searchElement[, fromIndex] )
      3     Returns the first index at which a given element can be found.
      4 
      5     Search is performed using *strict equality* comparison.
      6 
      7     Parameters
      8     ----------
      9     arr: ArrayLike
     10         Array-like object.
     11 
     12     searchElement: any
     13         Element to find.
     14 
     15     fromIndex: integer (optional)
     16         Starting index (if negative, the start index is determined relative to
     17         last element).
     18 
     19     Returns
     20     -------
     21     out: integer
     22         Index or -1.
     23 
     24     Examples
     25     --------
     26     // Basic usage:
     27     > var arr = [ 4, 3, 2, 1 ];
     28     > var idx = {{alias}}( arr, 3 )
     29     1
     30     > arr = [ 4, 3, 2, 1 ];
     31     > idx = {{alias}}( arr, 5 )
     32     -1
     33 
     34     // Using a `fromIndex`:
     35     > arr = [ 1, 2, 3, 4, 5, 2, 6 ];
     36     > idx = {{alias}}( arr, 2, 3 )
     37     5
     38 
     39     // `fromIndex` which exceeds `array` length:
     40     > arr = [ 1, 2, 3, 4, 2, 5 ];
     41     > idx = {{alias}}( arr, 2, 10 )
     42     -1
     43 
     44     // Negative `fromIndex`:
     45     > arr = [ 1, 2, 3, 4, 5, 2, 6, 2 ];
     46     > idx = {{alias}}( arr, 2, -4 )
     47     5
     48     > idx = {{alias}}( arr, 2, -1 )
     49     7
     50 
     51     // Negative `fromIndex` exceeding input `array` length:
     52     > arr = [ 1, 2, 3, 4, 5, 2, 6 ];
     53     > idx = {{alias}}( arr, 2, -10 )
     54     1
     55 
     56     // Array-like objects:
     57     > var str = 'bebop';
     58     > idx = {{alias}}( str, 'o' )
     59     3
     60 
     61     See Also
     62     --------
     63