Im playing around with NG2 and I am looking for the equivalent of angular.isArray
.
Yes, I tried to google it but no luck. Im probably thinking about this problem.
The method I try to use in my ng2-app is this:
function periodsFormat(dates, func) {
if (!angular.isArray(dates)) { return func(dates); }
return dates.map(func).join('-');
}
Surely it should work if I manage to replace (!angular.isArray...
with something NG2-ish. Thank you!
Update:
Thank you both, I ended doing this:
function periodsFormat(dates, func) {
if (!Array.isArray(dates)) { return func(dates); }
return dates.map(func).join('-');
}
I suspect you can just check the ctor:
if (dates.constructor !== Array) { ...
Since I believe you wouldn't be dealing with possible wrapped objects anymore.
Angular 1 checked for jQuery/jLite array's if I remember correctly which is why there was a special function for checking arrays.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With