Is there a Set literal in JavaScript?(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 字面量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:JavaScript 中有 Set 字面量吗?
基础教程推荐
- 在 contenteditable 中精确拖放 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- Bokeh Div文本对齐 2022-01-01
