pub(crate) fn construct_array(
        array_obj: &Value,
        array_contents: &[Value],
        context: &mut Context,
    ) -> Result<Value> {
        let array_obj_ptr = array_obj.clone();

        // Wipe existing contents of the array object
        let orig_length = array_obj.get_field("length", context)?.to_length(context)?;
        for n in 0..orig_length {
            array_obj_ptr.remove_property(n);
        }

        // Create length
        array_obj_ptr.set_property(
            "length".to_string(),
            PropertyDescriptor::builder()
                .value(array_contents.len())
                .writable(true)
                .enumerable(false)
                .configurable(false)
                .build(),
        );

        for (n, value) in array_contents.iter().enumerate() {
            array_obj_ptr.set_property(
                n,
                PropertyDescriptor::builder()
                    .value(value)
                    .configurable(true)
                    .enumerable(true)
                    .writable(true),
            );
        }
        Ok(array_obj_ptr)
    }
/// Utility function for creating array objects.
///
/// `array_obj` can be any array with prototype already set (it will be wiped and
/// recreated from `array_contents`)
Utility function for creating array objects.
`array_obj` can be any array with prototype already set (it will be wiped and
recreated from `array_contents`)
Utility function for creating array objects . ` array_obj ` can be any array with prototype already set ( it will be wiped and recreated from ` array_contents ` )
pub(crate) fn construct_array(
        array_obj: &Value,
        array_contents: &[Value],
        context: &mut Context,
    ) -> Result<Value> {
        let array_obj_ptr = array_obj.clone();
        // Wipe existing contents of the array object
        let orig_length = array_obj.get_field("length", context)?.to_length(context)?;
        for n in 0..orig_length {
            array_obj_ptr.remove_property(n);
        }
        // Create length
        array_obj_ptr.set_property(
            "length".to_string(),
            PropertyDescriptor::builder()
                .value(array_contents.len())
                .writable(true)
                .enumerable(false)
                .configurable(false)
                .build(),
        );
        for (n, value) in array_contents.iter().enumerate() {
            array_obj_ptr.set_property(
                n,
                PropertyDescriptor::builder()
                    .value(value)
                    .configurable(true)
                    .enumerable(true)
                    .writable(true),
            );
        }
        Ok(array_obj_ptr)
    }
pub ( crate ) fn construct_array ( array_obj : & Value , array_contents : & [ Value ] , context : & mut Context , ) -> Result < Value > { let array_obj_ptr = array_obj . clone ( ) ; // Wipe existing contents of the array object let orig_length = array_obj . get_field ( " " , context ) ? . to_length ( context ) ? ; for n in 0 .. orig_length { array_obj_ptr . remove_property ( n ) ; } // Create length array_obj_ptr . set_property ( " " . to_string ( ) , PropertyDescriptor :: builder ( ) . value ( array_contents . len ( ) ) . writable ( true ) . enumerable ( false ) . configurable ( false ) . build ( ) , ) ; for ( n , value ) in array_contents . iter ( ) . enumerate ( ) { array_obj_ptr . set_property ( n , PropertyDescriptor :: builder ( ) . value ( value ) . configurable ( true ) . enumerable ( true ) . writable ( true ) , ) ; } Ok ( array_obj_ptr ) }
Utility function for creating array objects.
Utility function for creating array objects .
array_obj
&Value
array_contents
&[Value]
context
&mut Context
array_obj
&Value
array_contents
&[Value]
context
&mut Context