function array_equal ( a, b ) { if ( a.length != b.length ) return false; a.sort(); b.sort(); for ( var i in a ) { if ( a[i] != b[i] ) return false; } return true; }; alert(array_equal([1,2], ['1','2']));