angular.isObject: This function is used to check whether a reference is object or not. The function angular.isObject will return true if passed reference is object else it will return false. Here in this tutorial we are going to explain how you can use this function to determine an object in AngularJs. You can use our online editor to edit and run the code online.
angular.isObject – Check if Reference is object | Example
Sytax for angular.isObject is as below-
Syntax –
angular.isObject Syntax
angular.isObject(value); |
The above function checks whether the passed string(reference) is isObject or not and on the basis of that it returns true or false.
Arguments
- value : This is reference to check.
Returns
- boolean : Returns true if reference is object else it will return false.
Now let us create a simple example to understand the above function.
Example
AngularJs check object type: Check If Object
<div ng-app="myApp"> <div ng-controller="myController"> <button ng-click="chackObjects()">Check Objects</button> <br/> Result for a = {{result1}}<br/> Result for b = {{result2}} </div> </div> |
If you run the above example it will produce the output something like this –
Note : Null s are not considered as object. JavaScript Arrays are object.