更新时间:2023-12-02 17:32:46
.splice
确实返回已删除的项目.但是,它也会在内部操作数组.这样可以防止您将任何内容链接到.splice
.您必须进行两个单独的调用:
.splice
does return the removed item. However, it also manipulates the array internally. This prevents you from chaining anything to .splice
; you must do two separate calls:
value = value.split(',');
value.splice(1, 1);
console.log(value.join(','));
如果执行value = value.splice(...)
,则value
被覆盖,并且数组丢失!
If you do value = value.splice(...)
, value
is overridden, and the array is lost!