I am creating a project using angularjs.I have variable like
$scope.test = null
$scope.test = undefined
$scope.test = ""
I want to check all null,undefined and empty value in one condition
I am creating a project using angularjs.I have variable like
$scope.test = null
$scope.test = undefined
$scope.test = ""
I want to check all null,undefined and empty value in one condition
You can do simple check
if(!a) {
// do something when `a` is not undefined, null, ''.
}
A very simple check that you can do:
Explanation 1:
if (value) {
// it will come inside
// If value is either undefined, null or ''(empty string)
}
Explanation 2:
(!value) ? "Case 1" : "Case 2"
If the value is either undefined , null or '' then Case 1 otherwise for any other value of value Case 2.