variable.constructor === Array
Simple example code Array.isArray() method checks whether the passed variable is an Array object.
<!DOCTYPE html> <html> <body> <script> let arr = [10, 20, 30, 40]; var res = Array.isArray(arr); console.log(res) console.log(arr) </script> </body> </html>
Using the instanceof operator
<script> let data = [10, 20, 30, 40]; var res = data instanceof Array; console.log(res) </script>
Checking the constructor property of the variable
<script> let data = [10, 20, 30, 40]; var res = data.constructor === Array console.log(res) </script>
Do comment if you have any doubts or suggestions on this JS Array topic.
Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.