Try this:
Code:

Object.prototype.flip = function()
{
var
map = {},
x;
for(x in this)
{
if(this.hasOwnProperty(x))
{
map[this[x]] = x;
}
}
return map;
}
Object.prototype.toArray = function()
{
var
i = this.length - 1,
result = new Array(this.length);
for(; i >= 0; --i)
{
result[i] = this[i];
}
return result;
}
Array.prototype.continuous = function()
{
var
result = [],
i = 0,
omitted = 0;
for(; i < this.length; ++i)
{
if(undefined == this[i])
{
++omitted;
}
else
{
result[i - omitted] = this[i];
}
}
return result;
}
Array.prototype.diff = function()
{
var
result,
map = this.flip(),
i = arguments.length - 1,
j;
for(; i >= 0; --i)
{
if(arguments[i] instanceof Array)
{
for(j = arguments[i].length - 1; j >= 0; --j)
{
map[arguments[i][j]] = this.length;
}
}
else
{
map[arguments[i]] = this.length;
}
}
map = map.flip();
map[this.length] = undefined;
map.length = this.length;
return map.toArray().continuous();
}
var
a = [5, 1, 3, 7, 6, 9, 8],
b = [3, 9];
alert(a.diff(b));

dumpfi