Open In App

AngularJS angular.isArray() Function

Last Updated : 06 Sep, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The angular.isArray() Function in AngularJS is used to return TRUE if the reference is an array and FALSE if it is not an array. 

Syntax:

angular.isArray(value);

Parameter:

  • value: It specifies the reference to check the value.

Return value: Returns TRUE if the value is an array else it will return FALSE. 

Example 1: This example describes the basic usage of angular.isArray() Function in AngularJS.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>angular.isArray()</title>
    <script src=
    </script>
</head>
  
<body ng-app="app" style="text-align:Center">
    <h1 style="color:green">GeeksforGeeks</h1>
    <h2>angular.isArray()</h2>
    <div ng-controller="geek">
        <b>Sorting Algos:</b>
        <div ng-repeat="i in sort">{{i.name}}</div>
        <br><br>isArray: {{isArray}}
    </div>
  
    <script>
        var app = angular.module("app", []);
        app.controller('geek', ['$scope', 
        function ($scope) {
            $scope.sort = [];
            var values = [
                { name: 'Merge sort' },
                { name: 'Quick sort' },
                { name: 'Bubble sort' }
            ];
            if (angular.isArray(values)) {
                $scope.isArray = true;
                angular.forEach(values, 
                function (value, key) {
                    $scope.sort.push(value)
                })
            }
        }]);
    </script>
</body>
  
</html>


Output:

isarray

 Example 2: This is another example that describes the usage of angular.isArray() Function in AngularJS.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>angular.isArray()</title>
    <script src=
    </script>
</head>
  
<body ng-app="app" style="text-align: Center">
    <h1 style="color: green">GeeksforGeeks</h1>
    <h2>angular.isArray()</h2>
    <div ng-controller="geek">
        <b>Input: </b>{{name}}
        <br /><br />
        <b>isArray:</b> {{isArray}}
    </div>
    <script>
        var app = angular.module('app', []);
        app.controller('geek', ['$scope',
            function ($scope) {
                var values = 'GeeksforGeeks';
                $scope.name = values;
                $scope.isArray = angular.isArray(values);
            },
        ]);
    </script>
</body>
  
</html>


Output:

isarray



Previous Article
Next Article

Similar Reads

Underscore.js _.isArray() Function
The Underscore.js is a JavaScript library that provides a lot of useful functions like the map, filter, invoke, etc even without using any built-in objects. The _.isArray() function is used to find whether the passed argument is an array or not. An array is a set of variables, constants, and special symbols. True will be returned if the object is a
3 min read
PHP | ReflectionParameter isArray() Function
The ReflectionParameter::isArray() function is an inbuilt function in PHP which is used to return TRUE if the specified parameter is an array, FALSE otherwise. Syntax: bool ReflectionParameter::isArray ( void ) Parameters: This function does not accept any parameters. Return Value: This function returns TRUE if the specified parameter is an array,
2 min read
JQuery | isArray() method
This isArray() Method in jQuery is used to determines whether the argument is an array. Syntax: jQuery.isArray( object ) Parameters: The isArray() method accepts only one parameter that is mentioned above and described below: object : This parameter is the object to test whether or not it is an array. Return Value: It returns the boolean value. Bel
2 min read
Lodash _.isArray() Method
Lodash _.isArray() method checks if the given value can be classified as an Array Value or not. Syntax:_.isArray(value);Parameters:value: This parameter holds the value that needs to be Checked for an Array.Return Value: This method returns a Boolean value. Example 1: In this example, we are checking whether the given value is an array or not and p
2 min read
TypeScript Array.isArray() Method
In TypesScript the isArray() method returns true if the value passed as a parameter is a type of array. If the value is indeed an array the function will return true, otherwise it will return false. Syntax:Array.isArray(value: any): booleanParametersvalue: The value that will be checked for array type.Return ValueIf the given value is an array then
1 min read
JavaScript Array isArray() Method
The isArray() method in JavaScript is used to determine whether a given value is an array or not. This method returns true if the argument passed is an array else it returns false. Syntax: Array.isArray(obj);Parameters: obj: This parameter holds the object that will be tested.Return value: This function returns the Boolean value true if the argumen
2 min read
AngularJS angular.isObject() Function
The angular.isobject() Function in AngularJS is used to determine if the parameter inside isobject function is an object or not. It returns true if the reference is an object or else false. Syntax: angular.isobject(value);Parameter: value: This parameter value validates whether the entered value is an object or not.Return Value: It returns true if
2 min read
AngularJS angular.isUndefined() Function
The angular.isUndefined() function in AngularJS is used to determine the value inside isUndefined function is undefined or not. It returns true if the reference is undefined otherwise returns false. Syntax: angular.isUndefined( value ) Parameter value: value: It is used to reference the value to check whether the value is defined or undefined.Retur
2 min read
AngularJS angular.isNumber() Function
The angular.isNumber() function in AngularJS is used to determine the parameter inside isNumber function is a number or not. It returns true if the reference is a number otherwise returns false. Syntax: angular.isNumber( value );Parameter value: value: It determines whether the entered value is a number or not.Return Value: It returns a boolean val
2 min read
AngularJS | angular.isString() Function
The angular.isString() function in AngularJS is used to determine the parameter inside isString function is a string or not. It returns true if the reference is a string otherwise returns false. Syntax: angular.isString( value ) Return Value: It returns true if the value passed is a string otherwise return false. Example: This example uses angular.
1 min read