gogoWebsite

JS find method

Updated to 7 minutes ago

usage

  1. The find() method returns the value of the first element of the array that passes the test (in-function judgment).

  2. Returns undefined if no element matches the condition.

  3. find() is not executed for empty arrays.

  4. find() does not change the original value of the array.

  5. (function(currentValue, index, arr),thisValue), where currentValue is the current item, index is the current index, arr is the current array

an actual example


        let test = [1, 2, 3, 4, 5];
        let a = (item => item > 3);
        (a); //4

        let b = (item => item == 0);
        (b); //undefined