Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the alternative for angular.isObject(value) in angular

I'm migrating from AngularJS to Angular version 12 In AngularJS, I have the following operations:

angular.isObject(value) angular.isDefined(value) angular.forEach(value)

I want to know the alternatives in angular

like image 275
tasmia firdose Avatar asked Sep 15 '26 22:09

tasmia firdose


1 Answers

Angular does not provide such methods. You can create your own replacements:

for angular.isObject you can do:

isObject(obj) {
   typeof obj === 'object' && obj !== null. 
}

for angular.forEach you have Object.entries which returns an iterable.

angular.isDefined is just

isDefined(obj) {
   typeof obj !== null && obj !== undefined. 
}
like image 96
Matthieu Riegler Avatar answered Sep 18 '26 12:09

Matthieu Riegler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!