How to replace an item in an array with JavaScript?

后端 未结 26 2244
执笔经年
执笔经年 2020-11-29 15:33

Each item of this array is some number.

var items = Array(523,3452,334,31, ...5346);

How do I replace some number in with array with a new on

26条回答
  •  生来不讨喜
    2020-11-29 15:59

    Here attached the code which replace all items in array

    var temp_count=0;
    layers_info_array.forEach(element => {
         if(element!='')element=JSON.parse(element);//change this line if you want other change method, here I changed string to object
         layers_info_array[temp_count]=element;
         temp_count++;
    });
    

提交回复
热议问题