TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

New JavaScript Set Methods

92 点作者 soheilpro11 个月前

11 条评论

esprehn11 个月前
I'm very excited this finally shipped everywhere! Prior to this Set wasn't much more than a Map<any, true> since it had no actual Set operations.
mcphage11 个月前
Oh, that's a relief. Having "set" objects in JS, without having any of the standard set operations, didn't make a lot of sense.
bsmth11 个月前
Blog post author here in case there's any feedback or questions. Thanks for sharing :)
评论 #40777735 未加载
wruza11 个月前
It was replaceAll in 2021 and now this! Who knows what we’ll get in 2030. Maybe Array.prototype.last() even.
评论 #40785229 未加载
orangepanda11 个月前
&gt; It&#x27;s also typically faster to check if an element is in a set as opposed to in an Array<p>What optimisations allow that? As sets in javascript maintain insertion order, aren’t lookups O(n) ?
评论 #40776651 未加载
评论 #40782048 未加载
评论 #40775981 未加载
philipwhiuk11 个月前
It&#x27;s a pity that you can&#x27;t implement a function in an object to consider it equal to another object with the same member values.
评论 #40783484 未加载
throw15675422811 个月前
This&#x27;ll help with AoC. Just need sensible tuples now and we&#x27;ll be golden. See you in ten years.
bavell11 个月前
Perhaps it&#x27;s asking too much but it would be great to see performance comparisons of these new set methods versus naive JS.<p>Not sure when I&#x27;ll have a chance to use them but seems pretty comprehensive in covering all the basics.
评论 #40786482 未加载
pipeline_peak11 个月前
[6,-2,2,-7].sort()<p>Result : [-2,-7,2,6]<p>Ladies and Gentlemen, the lingua franca of web programming.
评论 #40785650 未加载
评论 #40784890 未加载
评论 #40784972 未加载
评论 #40796344 未加载
twosdai11 个月前
Huh. I might actually start using sets over just simple objects. Never found a great reason to use them before these methods, other than to show off.
评论 #40777358 未加载
评论 #40780558 未加载
评论 #40778212 未加载
评论 #40789224 未加载
评论 #40777169 未加载
mrkeen11 个月前
Damn, in 2024?<p>Do Java next!