3 ms·
Thats why JavaScript has both undefined and null!
by bazoom42 4y ago
Thats why JavaScript has both undefined and null!
- deely3 4y agoDo we really need to differentiate between undef and null?
- bazoom42 4y agoNot necessarily, but it does allow a level of robustness to be able to distingish between values which have deliberately been assigned null, and values which have not been initialized correctly.
- mananaysiempre 4y agoLua does fine with only a nil, although it gets a tad annoying when you actually want to store a nil value in an array and end up creating a hole instead. (Arguably, the solution to that problem is to use your own marker object and not a nil when you need some sort of unspecified or default value which is not a literal absence of one.)