$.inArray test
$.inArray fails in IE6 and Chrome (13 win) when second parameter is null or undefined
HTML
<!DOCTYPE html>
<html>
<head>
<title>$.inArray test</title>
<script src="/dist/jquery.js" type="text/javascript"></script>
</head>
<body>
<div id="console"></div>
</body>
</html>
JavaScript
function print(text)
{
document.getElementById('console').innerHTML += text + '<br />';
}
function checkInArray(value, array)
{
try {
return 'Ok. Result: ' + $.inArray(value, array) + '<br />';
}
catch (e) {
return 'Error ' + e.message + '<br />';
}
}
print('Value in array');
print(checkInArray(1, [1]));
print('Value in empty array');
print(checkInArray(1, []));
print('Value in object');
print(checkInArray(1, {1: 2, 2: 1}));
print('Value in string');
print(checkInArray(1, 'string'));
print('Value in int');
print(checkInArray(1, 'int'));
print('Value in false');
print(checkInArray(1, false));
print('Value in undefined');
print(checkInArray(1, undefined));
print('Value in null');
print(checkInArray(1, null));