3 ms·
Off the top of my head: - There's both undefined and null - There's three ways to declare variable - typeof vs instanceof - for in vs for of - the way `thi
by GrantMoyer 2y ago
Off the top of my head:
- There's both undefined and null
- There's three ways to declare variable
- typeof vs instanceof
- for in vs for of
- the way `this` works
- semantics of functions called with the wrong number of args
There's far more that I can't immediately recall.
- throwawaymaths 2y agoprototypes vs class
- Lerc 2y agoA lot of that is what I had in mind. Things like for...of and let fix glaring problems by introducing new things instead of changing to maintain backwards compatibility. A lot of the fixes are just removing the old broken way of doing things. I'd still probably change 'for x of ...' to implicitly be 'const x' and require let if you are doing shenanigans with changing the values. I am surprisingly ok with null and undefined. Null means not a thing, undefined means there is not even the notion of the thing. I'm pretty sure there are more than three ways to declare a variable. x=5 let x=5 var x=5 window.x=5 window["x"]=5 //arguably the same as above. Object.defineProperty(window,"x",{value:5}) Object.assign(window,{x:5}) at least
- paulddraper 2y agoMany of those are setting properties, not variables. A variable reference can lookup properties on the global object, or other objects with ‘with’
- int_19h 2y ago> Null means not a thing, undefined means there is not even the notion of the thing. If only "undefined" was consistently the same as lack of variable / collection entry, it would be understandable. But as things are, {x: 1, y: undefined} is not the same as {x: 1} in many ways - indeed, so much so that TS distinguishes between these two cases in its type system.
- chuckadams 2y agoAnd just for fun, `typeof null` returns `object`, which is an acknowledged bug they'll never fix because compatibility.
- paulddraper 2y ago> three ways to declare a variable FWIW Python has three (default, nonlocal, and global). And many languages have two.
- codethief 2y ago> There's both undefined and null To make matters even worse, there's a difference between setting an object property to undefined as opposed to omitting it. So one could say there are two different "undefined"s.