pub(crate) fn last_index_of(
        this: &Value,
        args: &[Value],
        context: &mut Context,
    ) -> Result<Value> {
        // 1. Let O be ? ToObject(this value).
        let o = this.to_object(context)?;

        // 2. Let len be ? LengthOfArrayLike(O).
        let len = o.length_of_array_like(context)? as i64;

        // 3. If len is 0, return -1𝔽.
        if len == 0 {
            return Ok(Value::from(-1));
        }

        // 4. If fromIndex is present, let n be ? ToIntegerOrInfinity(fromIndex); else let n be len - 1.
        let n = if let Some(from_index) = args.get(1) {
            from_index.to_integer_or_infinity(context)?
        } else {
            IntegerOrInfinity::Integer(len - 1)
        };

        let mut k = match n {
            // 5. If n is -∞, return -1𝔽.
            IntegerOrInfinity::NegativeInfinity => return Ok(Value::from(-1)),
            // 6. If n ≥ 0, then
            //     a. Let k be min(n, len - 1).
            IntegerOrInfinity::Integer(n) if n >= 0 => min(n, len - 1),
            IntegerOrInfinity::PositiveInfinity => len - 1,
            // 7. Else,
            //     a. Let k be len + n.
            IntegerOrInfinity::Integer(n) => len + n,
        };

        let search_element = args.get(0).cloned().unwrap_or_default();

        // 8. Repeat, while k ≥ 0,
        while k >= 0 {
            // a. Let kPresent be ? HasProperty(O, ! ToString(𝔽(k))).
            let k_present = o.has_property(k, context)?;
            // b. If kPresent is true, then
            if k_present {
                // i. Let elementK be ? Get(O, ! ToString(𝔽(k))).
                let element_k = o.get(k, context)?;
                // ii. Let same be IsStrictlyEqual(searchElement, elementK).
                // iii. If same is true, return 𝔽(k).
                if Value::strict_equals(&search_element, &element_k) {
                    return Ok(Value::from(k));
                }
            }
            // c. Set k to k - 1.
            k -= 1;
        }
        // 9. Return -1𝔽.
        Ok(Value::from(-1))
    }
/// `Array.prototype.lastIndexOf( searchElement[, fromIndex ] )`
///
///
/// lastIndexOf compares searchElement to the elements of the array in descending order
/// using the Strict Equality Comparison algorithm, and if found at one or more indices,
/// returns the largest such index; otherwise, -1 is returned.
///
/// The optional second argument fromIndex defaults to the array's length minus one
/// (i.e. the whole array is searched). If it is greater than or equal to the length of the array,
/// the whole array will be searched. If it is negative, it is used as the offset from the end
/// of the array to compute fromIndex. If the computed index is less than 0, -1 is returned.
///
/// More information:
///  - [ECMAScript reference][spec]
///  - [MDN documentation][mdn]
///
/// [spec]: https://tc39.es/ecma262/#sec-array.prototype.lastindexof
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf
`Array.prototype.lastIndexOf( searchElement[, fromIndex ] )`
lastIndexOf compares searchElement to the elements of the array in descending order
using the Strict Equality Comparison algorithm, and if found at one or more indices,
returns the largest such index; otherwise, -1 is returned.

The optional second argument fromIndex defaults to the array's length minus one
. If it is greater than or equal to the length of the array,
the whole array will be searched. If it is negative, it is used as the offset from the end
of the array to compute fromIndex. If the computed index is less than 0, -1 is returned.

More information:
[ECMAScript reference][spec]
[MDN documentation][mdn]


` Array . prototype . lastIndexOf ( searchElement [ fromIndex ] ) ` lastIndexOf compares searchElement to the elements of the array in descending order using the Strict Equality Comparison algorithm and if found at one or more indices returns the largest such index ; otherwise - 1 is returned . The optional second argument fromIndex defaults to the array ' s length minus one . If it is greater than or equal to the length of the array the whole array will be searched . If it is negative it is used as the offset from the end of the array to compute fromIndex . If the computed index is less than 0 - 1 is returned . More information : [ ECMAScript reference ] [ spec ] [ MDN documentation ] [ mdn ]
pub(crate) fn last_index_of(
        this: &Value,
        args: &[Value],
        context: &mut Context,
    ) -> Result<Value> {
        // 1. Let O be ? ToObject(this value).
        let o = this.to_object(context)?;
        // 2. Let len be ? LengthOfArrayLike(O).
        let len = o.length_of_array_like(context)? as i64;
        // 3. If len is 0, return -1𝔽.
        if len == 0 {
            return Ok(Value::from(-1));
        }
        // 4. If fromIndex is present, let n be ? ToIntegerOrInfinity(fromIndex); else let n be len - 1.
        let n = if let Some(from_index) = args.get(1) {
            from_index.to_integer_or_infinity(context)?
        } else {
            IntegerOrInfinity::Integer(len - 1)
        };
        let mut k = match n {
            // 5. If n is -∞, return -1𝔽.
            IntegerOrInfinity::NegativeInfinity => return Ok(Value::from(-1)),
            // 6. If n ≥ 0, then
            //     a. Let k be min(n, len - 1).
            IntegerOrInfinity::Integer(n) if n >= 0 => min(n, len - 1),
            IntegerOrInfinity::PositiveInfinity => len - 1,
            // 7. Else,
            //     a. Let k be len + n.
            IntegerOrInfinity::Integer(n) => len + n,
        };
        let search_element = args.get(0).cloned().unwrap_or_default();
        // 8. Repeat, while k ≥ 0,
        while k >= 0 {
            // a. Let kPresent be ? HasProperty(O, ! ToString(𝔽(k))).
            let k_present = o.has_property(k, context)?;
            // b. If kPresent is true, then
            if k_present {
                // i. Let elementK be ? Get(O, ! ToString(𝔽(k))).
                let element_k = o.get(k, context)?;
                // ii. Let same be IsStrictlyEqual(searchElement, elementK).
                // iii. If same is true, return 𝔽(k).
                if Value::strict_equals(&search_element, &element_k) {
                    return Ok(Value::from(k));
                }
            }
            // c. Set k to k - 1.
            k -= 1;
        }
        // 9. Return -1𝔽.
        Ok(Value::from(-1))
    }
pub ( crate ) fn last_index_of ( this : & Value , args : & [ Value ] , context : & mut Context , ) -> Result < Value > { // 1. Let O be ? ToObject(this value). let o = this . to_object ( context ) ? ; // 2. Let len be ? LengthOfArrayLike(O). let len = o . length_of_array_like ( context ) ? as i64 ; // 3. If len is 0, return -1𝔽. if len == 0 { return Ok ( Value :: from ( - 1 ) ) ; } // 4. If fromIndex is present, let n be ? ToIntegerOrInfinity(fromIndex); else let n be len - 1. let n = if let Some ( from_index ) = args . get ( 1 ) { from_index . to_integer_or_infinity ( context ) ? } else { IntegerOrInfinity :: Integer ( len - 1 ) } ; let mut k = match n { // 5. If n is -∞, return -1𝔽. IntegerOrInfinity :: NegativeInfinity => return Ok ( Value :: from ( - 1 ) ) , // 6. If n ≥ 0, then //     a. Let k be min(n, len - 1). IntegerOrInfinity :: Integer ( n ) if n >= 0 => min ( n , len - 1 ) , IntegerOrInfinity :: PositiveInfinity => len - 1 , // 7. Else, //     a. Let k be len + n. IntegerOrInfinity :: Integer ( n ) => len + n , } ; let search_element = args . get ( 0 ) . cloned ( ) . unwrap_or_default ( ) ; // 8. Repeat, while k ≥ 0, while k >= 0 { // a. Let kPresent be ? HasProperty(O, ! ToString(𝔽(k))). let k_present = o . has_property ( k , context ) ? ; // b. If kPresent is true, then if k_present { // i. Let elementK be ? Get(O, ! ToString(𝔽(k))). let element_k = o . get ( k , context ) ? ; // ii. Let same be IsStrictlyEqual(searchElement, elementK). // iii. If same is true, return 𝔽(k). if Value :: strict_equals ( & search_element , & element_k ) { return Ok ( Value :: from ( k ) ) ; } } // c. Set k to k - 1. k -= 1 ; } // 9. Return -1𝔽. Ok ( Value :: from ( - 1 ) ) }
`Array.prototype.lastIndexOf( searchElement[, fromIndex ] )`
lastIndexOf compares searchElement to the elements of the array in descending order
using the Strict Equality Comparison algorithm, and if found at one or more indices,
returns the largest such index; otherwise, -1 is returned.
` Array . prototype . lastIndexOf ( searchElement [ fromIndex ] ) ` lastIndexOf compares searchElement to the elements of the array in descending order using the Strict Equality Comparison algorithm and if found at one or more indices returns the largest such index ; otherwise - 1 is returned .
this
&Value
args
&[Value]
context
&mut Context
this
&Value
args
&[Value]
context
&mut Context