score:1

Accepted answer

this is incorrect:

        let array1=[];
        array1=this.state.mainarray.slice;

mainarray.slice() is a copy, but mainarray.slice is a function. instead, begin with

        let array1 = this.state.mainarray.slice();

Related Query

More Query from same tag