chore(learn): Applied MDX format to Chinese curriculum files (#40462)
This commit is contained in:
@ -1,69 +1,53 @@
|
||||
---
|
||||
id: 596a8888ab7c01048de257d5
|
||||
title: deepcopy的
|
||||
challengeType: 5
|
||||
videoUrl: ''
|
||||
title: deepcopy的
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description">任务: <p>编写一个返回给定对象的深层副本的函数。 </p><p>副本不得与给定的对象相同。 </p><p>此任务不会测试: </p>具有属性属性的对象Date对象或具有Date对象属性的对象RegEx或具有RegEx对象属性的对象原型复制</section>
|
||||
# --description--
|
||||
|
||||
## Instructions
|
||||
<section id="instructions">
|
||||
</section>
|
||||
任务:
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
编写一个返回给定对象的深层副本的函数。
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>deepcopy</code>应该是一个功能。
|
||||
testString: assert(typeof deepcopy === 'function');
|
||||
- text: '<code>deepcopy({test: "test"})</code>应返回一个对象。'
|
||||
testString: 'assert(typeof deepcopy(obj1) === ''object'');'
|
||||
- text: 不应该返回提供的相同对象。
|
||||
testString: assert(deepcopy(obj2) != obj2);
|
||||
- text: 传递包含数组的对象时,应返回该对象的深层副本。
|
||||
testString: assert.deepEqual(deepcopy(obj2), obj2);
|
||||
- text: 传递包含另一个对象的对象时,应返回该对象的深层副本。
|
||||
testString: assert.deepEqual(deepcopy(obj3), obj3);
|
||||
副本不得与给定的对象相同。
|
||||
|
||||
```
|
||||
此任务不会测试:
|
||||
|
||||
</section>
|
||||
具有属性属性的对象Date对象或具有Date对象属性的对象RegEx或具有RegEx对象属性的对象原型复制
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
# --hints--
|
||||
|
||||
<div id='js-seed'>
|
||||
`deepcopy`应该是一个功能。
|
||||
|
||||
```js
|
||||
function deepcopy (obj) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
|
||||
assert(typeof deepcopy === 'function');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
### After Test
|
||||
<div id='js-teardown'>
|
||||
`deepcopy({test: "test"})`应返回一个对象。
|
||||
|
||||
```js
|
||||
console.info('after the test');
|
||||
assert(typeof deepcopy(obj1) === 'object');
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
不应该返回提供的相同对象。
|
||||
|
||||
```js
|
||||
// solution required
|
||||
assert(deepcopy(obj2) != obj2);
|
||||
```
|
||||
|
||||
/section>
|
||||
传递包含数组的对象时,应返回该对象的深层副本。
|
||||
|
||||
```js
|
||||
assert.deepEqual(deepcopy(obj2), obj2);
|
||||
```
|
||||
|
||||
传递包含另一个对象的对象时,应返回该对象的深层副本。
|
||||
|
||||
```js
|
||||
assert.deepEqual(deepcopy(obj3), obj3);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
|
Reference in New Issue
Block a user