Remove items from one array if not in the second array

前端 未结 5 2037
清酒与你
清酒与你 2021-01-21 02:49

I state that I have tried for a long time before writing this post.

For an InDesign script, I\'m working with two array of ListItems. Now I\'m trying to remove the items

5条回答
  •  無奈伤痛
    2021-01-21 03:20

    arr_A = ["a","b","d","f","g"];
    arr_B = ["a","c","f","h"];
    var newArr = [];
    var item
    while ( item = arr_B.shift() ) {
    	arr_A.contains ( item ) && newArr[ newArr.length ] = item ;
    }
    newArr;// ["a", "f"];

提交回复
热议问题