JavaScript 中有 Set 字面量吗?

编程入门 行业动态 更新时间:2024-10-11 21:25:58
本文介绍了JavaScript 中有 Set 字面量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我可以用 new Set(),同样我可以使用 Array 或 Object 或 Boolean 或 Number 构造函数.

I can make a Set with new Set(), same way I can use the Array or Object or Boolean or Number constructors.

但是是否有一套文字语法,比如数组、对象、布尔值、数字等?

But is there a set literal syntax, like there is for arrays, objects, booleans, numbers etc?

推荐答案

正如其他人所指出的,目前还没有 Set(或 Map)字面量语法.在这个 ES 讨论线程 并在 以下 Twitter 讨论中.

As others have pointed out, there is no Set (or Map) literal syntax yet. There have been a few ideas floating around, in this ES Discuss Thread and in the following twitter discussion.

几个建议的语法示例:

const set = {<1, "two", false>}; // by Brendan Eich const set = {. 1, "two", false .}; // by Axel Rauschmayer

不过,据我所知,目前还没有任何建议可以实施.

There are, as far as I can see, no proposals to implement any of them yet, though.

更多推荐

JavaScript 中有 Set 字面量吗?

本文发布于:2023-11-25 10:59:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629482.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中有   字面   JavaScript   Set

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!