.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(','));
If you do value = value.splice(...)
, value
is overridden, and the array is lost!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…