I am trying to have checkNull1
return true but it returns undefined. My understanding is that checkNull2
should work exactly the same way as checkNull1
but instead uses a variable to store the return result. What am I doing wrong?
Thanks.
function checkNull1(obj) {
return
(obj.a === null &&
obj.b === null &&
obj.c === null)
;
}
function checkNull2(obj) {
var isNull =
(obj.a === null &&
obj.b === null &&
obj.c === null)
;
return isNull;
}
function checkNull3() {
var nullObj = null;
return nullObj === null;
}
var object1 = {};
object1.a = null;
object1.b = null;
object1.c = null;
console.log("checkNull1: " + checkNull1(object1));
console.log("checkNull2: " + checkNull2(object1));
console.log("checkNull3: " + checkNull3());
JSFiddle: http://jsfiddle.net/Ravvy/ah8hn2qy/