【发布时间】:2017-09-11 03:45:58
【问题描述】:
如何比较两个 javascript 数组并创建两个包含缺失元素和新元素的新数组?数组元素将始终是字符串或数字,并且不能 100% 确定它们会以任何方式排序。
var array1= ['11', '13', '14', '18', '22', '23', '25'];
var array2= ['11', '13', '15', '16', '17', '23', '25', '31'];
var missing_elements = [];
var new_elements = [];
***Required Output:***
missing_elements= ['14', '18', '22']
new_elements= ['15', '16', '17', '31']
【问题讨论】:
-
欢迎来到 StackOverflow!到目前为止,您尝试过什么吗? StackOverflow 不是免费的代码编写服务,希望您能try to solve your own problem first。请更新您的问题以显示您已经尝试过的内容,并在minimal, complete, and verifiable example 中显示您面临的具体问题。欲了解更多信息,请参阅how to ask a good question,并拨打tour of the site
标签: javascript jquery arrays compare