From bff10652b403b20982921755b7b75415380dfa47 Mon Sep 17 00:00:00 2001 From: Sojin Park Date: Sat, 10 Aug 2024 10:33:05 +0900 Subject: [PATCH] docs: Add examples in cloneDeep --- docs/ko/reference/object/cloneDeep.md | 26 +++++++++++++++++----- docs/reference/object/cloneDeep.md | 16 +++++++++++++ docs/zh_hans/reference/object/cloneDeep.md | 16 +++++++++++++ 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/docs/ko/reference/object/cloneDeep.md b/docs/ko/reference/object/cloneDeep.md index dbf91e12..0b48286d 100644 --- a/docs/ko/reference/object/cloneDeep.md +++ b/docs/ko/reference/object/cloneDeep.md @@ -1,22 +1,22 @@ # cloneDeep -주어진 객체의 깊은 복사본을 생성합니다. +주어진 객체을 깊이 복사해요. -## Signature +## 인터페이스 ```typescript function cloneDeep(obj: T): T; ``` -### Parameters +### 파라미터 - `obj` (`T`): 복사할 객체예요. -### Returns +### 반환 값 (`T`): 주어진 객체의 깊은 복사본이에요. -## Examples +## 예시 ```typescript const num = 29; @@ -43,3 +43,19 @@ console.log(clonedNestedObj.a === nestedObj.a); // false console.log(clonedNestedObj.d === nestedObj.d); // false console.log(clonedNestedObj.d[2] === nestedObj.d[2]); // false ``` + +## 데모 + +::: sandpack + +```ts index.ts +import { cloneDeep } from 'es-toolkit/object'; + +const original = { a: { b: { c: 'deep' } }, d: [1, 2, { e: 'nested' }] }; +const cloned = cloneDeep(original); + +console.log(cloned); +console.log(original !== cloned); +``` + +::: diff --git a/docs/reference/object/cloneDeep.md b/docs/reference/object/cloneDeep.md index 85ae6c1a..9d3e9d53 100644 --- a/docs/reference/object/cloneDeep.md +++ b/docs/reference/object/cloneDeep.md @@ -43,3 +43,19 @@ console.log(clonedNestedObj.a === nestedObj.a); // false console.log(clonedNestedObj.d === nestedObj.d); // false console.log(clonedNestedObj.d[2] === nestedObj.d[2]); // false ``` + +## Demo + +::: sandpack + +```ts index.ts +import { cloneDeep } from 'es-toolkit/object'; + +const original = { a: { b: { c: 'deep' } }, d: [1, 2, { e: 'nested' }] }; +const cloned = cloneDeep(original); + +console.log(cloned); +console.log(original !== cloned); +``` + +::: diff --git a/docs/zh_hans/reference/object/cloneDeep.md b/docs/zh_hans/reference/object/cloneDeep.md index 2dde3f1a..3ccf4325 100644 --- a/docs/zh_hans/reference/object/cloneDeep.md +++ b/docs/zh_hans/reference/object/cloneDeep.md @@ -43,3 +43,19 @@ console.log(clonedNestedObj.a === nestedObj.a); // false console.log(clonedNestedObj.d === nestedObj.d); // false console.log(clonedNestedObj.d[2] === nestedObj.d[2]); // false ``` + +## 演示 + +::: sandpack + +```ts index.ts +import { cloneDeep } from 'es-toolkit/object'; + +const original = { a: { b: { c: 'deep' } }, d: [1, 2, { e: 'nested' }] }; +const cloned = cloneDeep(original); + +console.log(cloned); +console.log(original !== cloned); +``` + +:::