JavaScript Array method: isArray()
[this page | pdf | back links]
The isArray() method (when applied to the JavaScript
Array
object) returns true if an
object is an array, otherwise false.
It
has the following syntax with the following parameters. It returns a Boolean
as above.
Array.isArray(obj)
Parameter
|
Required / Optional
|
Description
|
obj
|
Required
|
Item to search for
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,th,tr,td {border: 1px solid black; border-collapse: collapse;}
</style>
</head>
<body>
<table>
<tr>
<th>Example</th>
<th>Resulting value of <code>x</code></th>
</tr>
<tr>
<td><code id="Example"></code></td>
<td><code id="Result"></code></td>
</tr>
</table>
<script>
var h = Array.isArray(["a","b"]);
var y = Array.isArray(3);
document.getElementById("Example").innerHTML =
'var h = Array.isArray(["a","b"]);<br>' +
'var y = Array.isArray(3);<br>' +
'var x = h + "|" + y;';
document.getElementById("Result").innerHTML = h + "|" + y;
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedJavaScriptMethodArrayIsArray() {
var h = [1, 2, 3]; return !!h.isArray;
} |
NAVIGATION LINKS
Contents | Prev | Next | JavaScript Arrays