Recursively remove null values from JavaScript object

前端 未结 8 901
挽巷
挽巷 2020-12-28 16:07

I have a JSON obj, after some operations (like delete some pieces), I print it and everything looks good except that I have some null values. How do I remove th

8条回答
  •  执笔经年
    2020-12-28 16:32

    How do you deletes your pieces ?

    Delete an array element with the delete operator leaves a hole in the array. Instead, you should use Array.splice which can remove properly an element from array.

提交回复
热议问题