* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
39 lines
1.2 KiB
Markdown
39 lines
1.2 KiB
Markdown
---
|
||
id: 587d825b367417b2b2512c8d
|
||
title: 创建ES6 JavaScript地图
|
||
challengeType: 1
|
||
videoUrl: ''
|
||
dashedName: create-an-es6-javascript-map
|
||
---
|
||
|
||
# --description--
|
||
|
||
新版本的JavaScript为我们提供了一个内置的Map对象,它提供了我们在上一次挑战中手工编写的大部分功能。此Map对象虽然与常规JavaScript对象类似,但它提供了一些普通对象缺少的有用功能。例如,ES6 Map跟踪添加到其中的项目的插入顺序。以下是其方法的更完整概述: `.has(key)`基于键的存在返回true或false `.get(key)`返回与键相关联的值`.set(key, value)`设置新键,值对`.delete(key)`删除一个键,值对`.clear()`删除所有键值对`.entries()`以插入顺序返回所有键的数组`.values()`返回插入中所有值的数组order说明:定义一个JavaScript Map对象并为其分配一个名为myMap的变量。添加密钥,值对`freeCodeCamp` , `Awesome!`它。
|
||
|
||
# --hints--
|
||
|
||
myMap对象存在。
|
||
|
||
```js
|
||
assert(typeof myMap === 'object');
|
||
```
|
||
|
||
myMap包含键值对`freeCodeCamp` , `Awesome!` 。
|
||
|
||
```js
|
||
assert(myMap.get('freeCodeCamp') === 'Awesome!');
|
||
```
|
||
|
||
# --seed--
|
||
|
||
## --seed-contents--
|
||
|
||
```js
|
||
```
|
||
|
||
# --solutions--
|
||
|
||
```js
|
||
// solution required
|
||
```
|