Skip to content

Instantly share code, notes, and snippets.

@lelinhtinh
Last active August 29, 2015 14:05
Show Gist options
  • Save lelinhtinh/d8155281d3522444ccb9 to your computer and use it in GitHub Desktop.
Save lelinhtinh/d8155281d3522444ccb9 to your computer and use it in GitHub Desktop.
Lấy ra mảng khác biệt từ 2 mảng, Trừ 2 mảng trong javascript
// http://stackoverflow.com/a/8211012
var array1 = ["test1", "test2", "test3", "test4"];
var array2 = ["test1", "test2", "test3", "test4", "test5", "test6"];
var _array = new Array();
_array = jQuery.grep(array2, function(item) {
return jQuery.inArray(item, array1) < 0;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment