Q:

removing elements from an array from another array in javascript

Hi i need to remove the array from another array.Below is the code that i had tried
var dummyObj = ["item1"];
var dummyArray = [ "item1", "item3", "item2"];

var data1=removeFromArray(dummyArray, dummyObj);

console.log("data1"+data1)

function removeFromArray(array, item)
{
while((index = array.indexOf(item)) > -1)
array.splice(index,1);
return array
}

below is my output
item1,item3,item2

But the required output is
item3,item2

Dont know where i am going wrong.Any help regarding this will be much helpful

A:

You argument  item is an   is an array object so you have to use it like  item[0]
 while((index = array.indexOf(item[0])) > -1)

if dummyObj contains for than one values then you have to add an extra loop
function removeFromArray(array, item)
{
for(var j=0;j<item.length;j++){
while((index = array.indexOf(item[j])) > -1)
array.splice(index,1);

}
return array
}

