I don't know if I am asking a valid question or not, but I am curious why PHP, JavaScript, Python interpret null
differently
Javascript :
console.log(null === 0); // Outputs false
console.log(null + 1); //Outputs 1 , why ? if null isn't equal to zero
PHP
var_dump(null === 0);
// outputs boolean false
var_dump(null + 1);
// outputs int 1, why if null being not equals to zero ?
Python :
>>None == 0
>>false
Since python None is singleton object, so addition to its gives the error
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
Curios about how other language interpret NULL
? And what it should be ?
And if Null
isn't equals to Zero
, why doing a addition on it , it behaves like Zero
?