I have two arrays
var array1 = new Array ["a", "b", "c", "d", "e"];
var array2 = new Array ["a", "c", "d"];
I want to remove elements of array2 from array1
Result ["b", "e"]
Is there anything like
array1 = array1.remove(array2)
Note I'm using jquery-1.9.1
Array elements can be deleted using the JavaScript operator delete . Using delete leaves undefined holes in the array. Use pop() or shift() instead.
pop() function: This method is used to remove elements from the end of an array. shift() function: This method is used to remove elements from the start of an array. splice() function: This method is used to remove elements from the specific index of an array.
Try:
var diff = $(array1).not(array2).get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With