HarmonyOS 字符串字符串数组我想移除其中某个元素要怎么实现?

1、要移除第二个

2、要移除指定字符(存在或不存在)

阅读 614
1 个回答

1.移除第二个元素this.List.splice(2, 1)

2.移除指定元素:

const words = ['spray', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter((word) => word.length > 6);
console.log(result);