Open In App
Related Articles

AngularJS angular.isFunction() Function

Improve Article
Improve
Save Article
Save
Like Article
Like

The angular.isFunction() Function in AngularJS is used to determine if the parameter inside isFunction function is a function or not. It returns true if the reference is a function else false. 

Syntax:

angular.isFunction(value);

Parameter:

  • value: This parameter specifies whether the passed value is a function or not.

Return Value: It returns true if the value passed is a function else false.

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

HTML




<!DOCTYPE html>
<html>
  
<head>
    <script src=
"//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js">
    </script>
    <title> angular.isFunction() </title>
</head>
  
<body ng-app="app" 
      style="text-align:center">
    <h1 style="color:green">
        GeeksforGeeks
    </h1>
    <h2>angular.isFunction()</h2>
    <div ng-controller="geek">
        <b>Input1: </b>
        <span>
            <code>
                obj = [{ name: "Abc"}, { name: "Xyz"}];
            </code>
        </span><br
        <b>IsFunction: </b> {{isFunction1}}<br />
        <br><br
        <b>Input2: </b
        <code>
            var Add = function () {
                return null;
            };
        </code><br>
        <b>IsFunction:</b> {{isFunction2}}
    </div>
    <script>
        var app = angular.module("app", []);
        app.controller('geek', ['$scope', function($scope) {
            var obj = [{
                name: "Abc"
            }, {
                name: "Xyz"
            }];
            var Add = function() {
                return null;
            };
            $scope.isFunction1 = angular.isFunction(obj);
            $scope.isFunction2 = angular.isFunction(Add);
        }]);
    </script>
</body>
</html>


Output:

isFunction

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

HTML




<!DOCTYPE html>
<html>
  
<head>
    <script src=
"//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js">
    </script>
    <title> angular.isFunction() </title>
</head>
  
<body ng-app="app" 
      style="text-align:center">
    <h1 style="color:green">
        GeeksforGeeks
    </h1>
    <h2>angular.isFunction()</h2>
    <div ng-controller="geek"
        <b>Input1: </b
        <span>
            <code>
                var arr = ['DSA','Algorithms','Web tech'];
            </code>
        </span><br
        <b>IsFunction: </b> {{isFunction1}}<br />
        <br><br
        <b>Input2: </b
            <code>
                Add = () =>{ return null; };
            </code><br
        <b>IsFunction:</b> {{isFunction2}}
    </div>
    <script>
        var app = angular.module("app", []);
        app.controller('geek', ['$scope', function($scope) {
            var arr = ['DSA', 'Algorithms', 'Web tech'];
            Add = () => {
                return null;
            };
            $scope.isFunction1 = angular.isFunction(arr);
            $scope.isFunction2 = angular.isFunction(Add);
        }]);
    </script>
</body>
</html>


Output:

 


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 06 Sep, 2022
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials