可能重复:
使用 jQuery 比较两个数组
我需要一个 Javascript 或 jQuery 函数来确定一个数组是否包含另一个数组的所有值。第二个数组可以有比第一个更多的值。
这应该返回true
or false
。例如。
comparing array1 = [1,2,3] and array2 = [1,2] should return false
comparing array1 = [1,2,3] and array2 = [1,1,2] should return false
comparing array1 = [1,2,3] and array2 = [3,2,1] should return true
comparing array1 = [1,2,3] and array2 = [1,2,1,3] should return true
性能不是问题。谢谢!