We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JavaScript的默认对象表示方式 {} 可以视为其他语言中的 Map 和 Dictionary 的数据结构,即一组键值对。但是 JavaScript 的对象有个小问题,即键必须是字符串。但实际上Number或者其他数据类型作为键也是非常合理的。为了解决这个问题,最新的ES6规范引入了新的数据类型Map和 Set。
{}
Map
Dictionary
JavaScript
Set
Set是一种叫做集合的数据结构,Map是一种叫做字典的数据结构
const array = [2,3,5,4,5,2,2]; const newArray = [...new Set(array)]; // [2,3,5,4]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
产生原因
JavaScript的默认对象表示方式
{}
可以视为其他语言中的Map
和Dictionary
的数据结构,即一组键值对。但是JavaScript
的对象有个小问题,即键必须是字符串。但实际上Number或者其他数据类型作为键也是非常合理的。为了解决这个问题,最新的ES6规范引入了新的数据类型Map
和Set
。应用场景
数组去重
模拟实现 Set
The text was updated successfully, but these errors were encountered: