Thanks for your input mmerlinn, here is bit more detail.
My intention is to prototype a unique function for arrays that returns a new array without duplicate elements. I believe that a unique function was added to JavaScript 1.5, but I'm coding this for IE, hence I'm stuck using JavaScript 1.3.
The problem appears to be with the evaluation after the if statement, even if the elements match the code does not step into the block of code following the if statement. Code with comments pasted below.
Array.prototype.unique = function()
{
var i;
var j;
var b=new Array();
//loops through array
main:for(i=0;i<this.length;i++)
{
//loops through array b which has initial lenght of 0
for (j=0;j<b.length;j++)
{
//compares current element from array to all elements contained in array b
//if a match is found the current iteration is stopped and the code starts the next iteration of main
if(this==b[j])
{
continue main;
}
}
//if no match is found the current element is inserted into array b.
b[b.length]=this;
}
return b;
}
Here is a portion of the array being passed;
title=" language: japanese"><span>ja</span></span>
title=" language: japanese"><span>ja</span></span>
title=" language: english"><span>en</span></span>
title=" language: english"><span>en</span></span>
title=" language: korean"><span>ko</span></span>
As have the code written.
On the first iteration the this[0] is compared to b[0] which is null,therefore there is no match the code steps over the if statement and the text is written b[0] by the next block of code.
On the second iteration the this[1] is compared to b[0], these two elements should match one another, hence the code should step into the if statement where the continue should break the iteration and step back to the block of code labeled main to begin the next iteration.
The evaluation is not working correctly and every element of the array is written to array b. The odd thing is that i can hard code the value into the evaluation and it works as expected.