want to check null values. any()
method returns null
or array of matched result (actually there's a match()
method inside which is returned).
$scope.isMobileBrowser = !isMobile.any() ? false : true;
If any()
method returns null I want false
to be assigned to $scope.isMobileBrowser
variable, otherwise true
. will the over mentioned snippet fail in any probable case? Is there any other more efficient workaround?
for more details of isMobile
object:
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
test()
instead ofmatch()
.String.match
does not return a string. It returnsnull
orArray
.any
method as well too check what values will be returned.