js 判断数组A里的值是否存在数组B里 2019-05-31 本文已影响0人 风中追风秦风 需求:A是全部的商品数组,B是选中的商品数组,判断没选中的商品.并且输出选中跟没选中商品 var A = ['1','ew','as','abc']; var B = ['as']; for (var i = 0;i<A.length;i++) { B.indexOf(A [i]) >-1? console.log(A [i] +"正确"): console.log(A [i] +"错误"); } 非常简单