Tutorialsplane

AngularJs Check if Reference is Array


AngularJs Check if Reference is Array – You can use the function angular.isArray() to chack whether a variable is array or not in AngularJs. Here in this tutorial we are going to explain how you can use angular.isArray() in AngularJs. You can use our online editor to edit and run the code online.


AngularJs Check if Reference is Array | Check if Variable is Array | Example

Syntax

Syntax for angular.isArray() function is –

Angularjs Check if Variable is Array | Syntax :

angular.isArray(var);

Agruments

Return

This will return true if variable or string is array else false.

Example

Let us create a simple example to check if given string is array-

AngularJs Check if String is Array:




 
 

  
<div ng-app="myApp">  
<div ng-controller="myController">  
	
    <button ng-click="checkArray()">Example1 </button>
	<br/>
	 <button ng-click="checkArray1()">Example2</button>
	<br/>
	
</div> 
</div>
  

Try it »

If you run the above example it will produce output something like this –