Revision: 37202
Updated Code
at December 7, 2010 07:43 by Nettuts
Updated Code
var unique = function(origArr) {
var newArr = [],
origLen = origArr.length,
found,
x, y;
for ( x = 0; x < origLen; x++ ) {
found = undefined;
for ( y = 0; y < newArr.length; y++ ) {
if ( origArr[x] === newArr[y] ) {
found = true;
break;
}
}
if ( !found) newArr.push( origArr[x] );
}
return newArr;
}
var myarray = ['jeffrey', 'allie', 'patty', 'damon', 'zach', 'jeffrey', 'allie', 'patty', 'damon', 'zach', 'joe'];
myarray = unique(myarray);
alert(myarray.join(', '));
Revision: 37201
Updated Code
at December 7, 2010 05:56 by Nettuts
Updated Code
var unique = function(origArr) {
var newArr = [],
origLen = origArr.length,
found,
x = 0; y = 0;
for ( x = 0; x < origLen; x++ ) {
found = undefined;
for ( y = 0; y < newArr.length; y++ ) {
if ( origArr[x] === newArr[y] ) {
found = true;
break;
}
}
if ( !found) newArr.push( origArr[x] );
}
return newArr;
}
var myarray = ['jeffrey', 'allie', 'patty', 'damon', 'zach', 'jeffrey', 'allie', 'patty', 'damon', 'zach', 'joe'];
myarray = unique(myarray);
alert(myarray.join(', '));
Revision: 37200
Updated Code
at December 6, 2010 03:42 by Nettuts
Updated Code
var unique = function(origArr) {
var newArr = [],
origLen = origArr.length,
found,
x = 0; y = 0;
for ( x = 0; x < origLen; x++ ) {
found = undefined;
for ( y = 0; y < newArr.length; y++ ) {
if ( origArr[x] === newArr[y] ) found = true;
}
if ( !found) newArr.push( origArr[x] );
}
return newArr;
}
var myarray = ['jeffrey', 'allie', 'patty', 'damon', 'zach', 'jeffrey', 'allie', 'patty', 'damon', 'zach', 'joe'];
myarray = unique(myarray);
alert(myarray.join(', '));
Revision: 37199
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 6, 2010 03:34 by Nettuts
Initial Code
var unique = function(origArr) {
var newArr = [],
origLen = origArr.length,
found = false,
x = 0; y = 0;
for ( x = 0; x < origLen; x++ ) {
found = false;
for ( y = 0; y < newArr.length; y++ ) {
if ( origArr[x] === newArr[y] ) found = true;
}
if ( !found) newArr.push( origArr[x] );
}
return newArr;
}
var myarray = ['jeffrey', 'allie', 'patty', 'damon', 'zach', 'jeffrey', 'allie', 'patty', 'damon', 'zach'];
myarray = unique(myarray);
console.log(myarray);
Initial URL
http://jsfiddle.net/ARnL3/
Initial Description
Simple function that filters out any duplicate items in an array.
Initial Title
Remove Duplicate Values from Array
Initial Tags
javascript, array, filter
Initial Language
JavaScript