Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   
   HTML   
   CSS   
   JAVA SCRIPT   
   JQUERY   




isArray() - FUNCTION


isArray() Function is used to check if a variable is an Array or not.


Let us say we have the below array with four elements.


var x = [5, 8, 2, 9]
JavaScript isArray()-Function


And we want to check if the variable x holds an Array or not?


And isArray() function helps us achieve the above.


Let us see in the below example.


Example :



<html>
<body>  
<script>

	var x = [5, 8, 2, 9]
	var y = Array.isArray(x)
	
	if (y == true) {
    	document.write("Is an Array")
    }	
    else if (y == false) {
    	document.write("No!! Is not an Array")
    }
	    
</script>      
</body>
</html>


Output :



  Is an Array