Nice article, it would be good to explain why such behaviors, for example isNaN actually makes use of js been weakly typed (js will try to convert anything, so if it expects a number, it will try to convert what you pass to a number) so isNaN("foo") = true, but isNaN("16") = false, because Number("foo") = NaN, but Number("16") = 16 so this is not a bug, or a flaw, it's just implicit conversion in action....also the fact that typeof null = "object", although controversial, is because how js was thought to be used, first everything is a object (including numbers and string, although treated as primitives) so null was conceived to be used as "an object with no defined value" and undefined was conceived to be "the absence of an object, or a object which was declared, but not yet initialized" that's why if you try retrieving a attribute that doesn't exist, it's value is undefined and that's why in json you have null but not undefined becaude you can have a object that has no value, but you can't have a object that doesn't exist....perhaps those kind of explanations were beyond the scope of the post, but i think they add to the undestanding behind the language and how it works, instead of just this feeling that people who created it and who manages it are just dumb hahah
Nice article, it would be good to explain why such behaviors, for example isNaN actually makes use of js been weakly typed (js will try to convert anything, so if it expects a number, it will try to convert what you pass to a number) so
isNaN("foo") = true
, butisNaN("16") = false
, becauseNumber("foo") = NaN
, butNumber("16") = 16
so this is not a bug, or a flaw, it's just implicit conversion in action....also the fact thattypeof null = "object"
, although controversial, is because how js was thought to be used, first everything is a object (including numbers and string, although treated as primitives) sonull
was conceived to be used as "an object with no defined value" andundefined
was conceived to be "the absence of an object, or a object which was declared, but not yet initialized" that's why if you try retrieving a attribute that doesn't exist, it's value isundefined
and that's why in json you havenull
but notundefined
becaude you can have a object that has no value, but you can't have a object that doesn't exist....perhaps those kind of explanations were beyond the scope of the post, but i think they add to the undestanding behind the language and how it works, instead of just this feeling that people who created it and who manages it are just dumb hahahThanks for you suggestion man, I have edited that part. :)