【发布时间】:2018-05-22 12:22:22
【问题描述】:
我想从一个数组中找到一个特定元素并从该特定数组中删除所有下一个元素。
下面是我的代码:
var data1 = [a,b,c,d,e,f,g,h];
var data2 = c; // this is element, that i want to find from data1 and
remove all next element i.e. d, e, f, g, h .
我想要输出如下:var res = [a,b,c];
谢谢,
【问题讨论】:
-
遍历数组,寻找你的元素,停止循环。
标签: javascript jquery