is-array
Version:
Check if the given value is an Array
46 lines • 1.67 kB
HTML
<html>
<head>
<title>isArray Tests</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
.fail {
color: red;
}
.pass {
color: green;
}
</style>
</head>
<body>
<ul id="results"></ul>
<script src="../build/build.js"></script>
<script>
var isArray = require('isArray');
var results = document.getElementById('results');
function assert(val, text) {
results.innerHTML += '<li class="' + (val === true?'pass':'fail') + '">' + (val === true?'PASS':'FAIL') + ': ' + text + '</li>';
if (val !== true) window.testsPassed = false;
}
assert(isArray([]), '`[]` is an array.');
assert(isArray([1]), '`[1]` is an array.');
assert(isArray([1, 2, 3]), '`[1, 2, 3]` is an array.');
assert(!isArray(""), '`""` is not an array.');
assert(!isArray("foo"), '`"foo"` is not an array.');
assert(!isArray(5), '`5` is not an array.');
assert(!isArray(null), '`null` is not an array.');
assert(!isArray(undefined), '`undefined` is not an array.');
assert(!isArray(true), '`true` is not an array.');
assert(!isArray(false), '`false` is not an array.');
assert(!isArray({}), '`{}` is not an array.');
assert(!isArray({length: 1}), '`{length: 1}` is not an array.');
(function () {
assert(!isArray(arguments), '`arguments` is not an array.');
}());
(function () {
assert(!isArray(arguments), '`arguments` is not an array.');
}(1, 2, 3));
window.testsPassed = window.testsPassed != false;
</script>
</body>
</html>