4 ms·
ES2021 Features
- carl_dr 5y agoThey are seemingly small upgrades, but the logical assignment operators and visual separation of numbers are really nice to have - two things I definitely miss from Ruby.
- kamilafsar 5y agoMDN has a bit more info on the new FinalizationRegistry API. Has anyone ideas about good use cases for this? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- slmjkdbtl 5y agohad a use case a couple days ago in an observer pattern where a computed observable's parent should drop the subscription event feom the sub list when the computed child is no longer around, ended up only using WeakRef
- bungalilac 5y agox += y; x = x + y; x = y; x = x y; x ||= y; x || (x = y); // Why? // Why not x ||= y; x = x || y;? let fee = 123_00; // $123 (12300 cents, apparently) // Why not 12300? let amount = 123_4500; // 123.45 (4-fixed financial) // Why not 1234500? // Why not just ignore those underscore and let Indians type like 3_00_00_000 // or Japaneses type like 1234_0000
- Ennea 5y agoRegarding the numerical separators: they're for readability, and readability only. They do not change the numbers in any way. 12300 is the same as 123_00 is the same as 1_2_3_0_0. Up to you entirely.
- tardismechanic 5y agoBecause "x = x || y;" would always perform the assignment due to precedence. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR_assignment#short-circuit_evaluation https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- dvh 5y agoAnd this is why we have so many languages. Language starts not so good, very limited, then features are added that makes it really popular, more and more features are added till it reaches the point where it no longer resembles the original that made it popular, mature codebases have multiple different styles, you look at the piece of code and think wtf is this supposed to do? People are fed up and start new language with limited set of features.
- zkldi 5y agoThese articles always seem to pop up everytime there's a JS language update - and they're all just copy-pasted content from MDN.
- tardismechanic 5y agoIf you click thru to the linked TC39 proposal [1], you will find that the site author is also one of its "Champion"s - so you know makes sense they would be stoked about it. Also, personally I find MDN content somehow unnecessarily dense, especially for beginners, and actually appreciate this kind of content. YMMV. [1] https://github.com/tc39/proposal-logical-assignment https://github.com/tc39/proposal-logical-assignment