为什么我可以正确地将字符串添加到一个集合中?

发布于 2025-01-23 05:28:00 字数 251 浏览 2 评论 0原文

第一个示例。 中写下字符串。

let set = new Set('Emily', 'Mag');

我不能仅在() “在此处输入图像说明”

'mag'在哪里?字符串是可以的,为什么不添加到集合?

First example. I can't add string just writing it in ().

let set = new Set('Emily', 'Mag');

enter image description here

Where's 'Mag'? String is iterable, why doesn't it add to Set collection?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

多孤肩上扛 2025-01-30 05:28:00

我认为语法有些关闭。您可能要寻找的是以下内容:

let set = new Set(['Emily', 'Mag']);

希望它有帮助!

I think the syntax is slightly off. What you might be looking for is the following:

let set = new Set(['Emily', 'Mag']);

Hope it helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文