Hello friends,
Today we learn how to check a function exist or not. In angular js, IsFunction() is used to find out the function exist or not. If the function exists it returns true else it will return false.
Syntax:
angular.isFunction(value);
value is the function name that we want to check. Let's take an example to understand it.
<!DOCTYPE html>
<html ng-app="">
<head>
<title>AngularJS code</title>
<script SRC="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js">
</script>
</head>
<body>
<fieldset>
<legend>AngularJS IsFunction()</legend>
<script>
function functionName()
{
return "function name";
}
var str = "new string obj";
document.write(angular.isFunction(functionName));
document.write("</br>");
document.write(angular.isFunction(str));
</script>
</fieldset>
</body>
</html>
Output of above is:
true
false
0 Comment(s)