如何比較兩個javascript數組並創建兩個缺失和新元素的新數組?數組元素將始終是字符串或數字,並不能100%確定它們將以任何方式排序。比較兩個數組,並使用純javascript或jquery創建兩個新數組,並使用缺失和新元素
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不是一個免費的代碼寫入服務,並且期待你 [嘗試先解決你自己的問題](http://meta.stackoverflow.com/questions/261592)。 請更新您的問題,以顯示您已經嘗試過的內容,顯示您在 [最小,完整和可驗證示例](http://stackoverflow.com/help/mcve)中遇到的具體問題。 欲瞭解更多信息,請參閱 [如何問一個好問題], 並採取 [網站之旅](http:// http:// stackoverflow.com/tour) –