在JavaScript中有一套Set literal吗? [英] Is there a Set literal in JavaScript?

查看:101
本文介绍了在JavaScript中有一套Set literal吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以设置新的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 Discussion Thread 以及以下微博讨论

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 literal吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆