Javascript wrong output [duplicate]

In the Javascript code, I’m passing response.data.var1 as false from the backend.
However, through the if condition, instead of printing “4???”, the output is “3****”.

$scope.var1 = response.data.var1;
alert(response.data.var1);  // Output: false
alert($scope.var1);         // Output: false

if($scope.var1) {
    alert("3****");   // Output: "3****" instead of "4???"
} else {
    alert("4???");
}

Can someone please explain what’s going on?