New issue
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.prototype.get(), has() 추가 #11171
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
files/ko/web/javascript/reference/global_objects/map/get/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
title: Map.prototype.get() | ||
slug: Web/JavaScript/Reference/Global_Objects/Map/get | ||
--- | ||
|
||
{{JSRef}} | ||
|
||
**`get()`** 메서드는 `Map` 객체에서 특정 요소를 반환합니다. 만약 주어진 키와 관련된 값이 객체라면 해당 객체에 대한 | ||
참조만 가져오고, 해당 객체에 대한 모든 변경은 `Map` 내에서 효율적으로 수정됩니다. | ||
|
||
{{EmbedInteractiveExample("pages/js/map-prototype-get.html")}} | ||
|
||
## 구문 | ||
|
||
```js-nolint | ||
get(key) | ||
``` | ||
|
||
### 매개변수 | ||
|
||
- `key` | ||
- : `Map` 객체에서 반환받을 요소의 키 | ||
|
||
### 반환 값 | ||
|
||
명시된 키와 연관된 요소 혹은 `Map` 객체에서 해당 키를 찾을 수 없는 경우 {{jsxref("undefined")}}. | ||
|
||
## 예제 | ||
|
||
### get() 사용하기 | ||
|
||
```js | ||
const myMap = new Map(); | ||
myMap.set('bar', 'foo'); | ||
|
||
console.log(myMap.get('bar')); // Returns "foo" | ||
console.log(myMap.get('baz')); // Returns undefined | ||
``` | ||
|
||
### get()을 사용하여 객체에 대한 참조 검색 | ||
|
||
```js | ||
const arr = []; | ||
const myMap = new Map(); | ||
|
||
myMap.set('bar', arr); | ||
|
||
myMap.get('bar').push('foo'); | ||
|
||
console.log(arr); // ["foo"] | ||
console.log(myMap.get('bar')); // ["foo"] | ||
``` | ||
|
||
맵이 원본 객체에 대한 참조만 보유하고 있다는 것은 해당 객체는 예측하지 못한 메모리 문제가 발생할 소지가 있는 가비지 수집이 되지 않음을 | ||
의미합니다. 만약 맵에 저장되어 있는 객체가 원본 객체와 동일한 수명을 가지게 하려면 {{jsxref("WeakMap")}}을 고려하시기 | ||
바랍니다. | ||
|
||
## 명세서 | ||
|
||
{{Specifications}} | ||
|
||
## 브라우저 호환성 | ||
|
||
{{Compat}} | ||
|
||
## 같이 보기 | ||
|
||
- {{jsxref("Map")}} | ||
- {{jsxref("Map.prototype.set()")}} | ||
- {{jsxref("Map.prototype.has()")}} |
51 changes: 51 additions & 0 deletions
51
files/ko/web/javascript/reference/global_objects/map/has/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
title: Map.prototype.has() | ||
slug: Web/JavaScript/Reference/Global_Objects/Map/has | ||
--- | ||
|
||
{{JSRef}} | ||
|
||
**`has()`** 메서드는 주어진 키에 해당하는 요소가 존재 여부를 가리키는 불리언 값을 반환합니다. | ||
|
||
{{EmbedInteractiveExample("pages/js/map-prototype-has.html")}} | ||
|
||
## 구문 | ||
|
||
```js-nolint | ||
has(key) | ||
``` | ||
|
||
### 매개변수 | ||
|
||
- `key` | ||
- : `Map` 객체에서 존재를 확인할 요소의 키 | ||
|
||
### 반환 값 | ||
|
||
만약 주어진 키에 해당하는 요소가 `Map`객체에 존재한다면 `true`, 그렇지 않으면 `false` | ||
|
||
## 예제 | ||
|
||
### has() 사용하기 | ||
|
||
```js | ||
const myMap = new Map(); | ||
myMap.set("bar", "foo"); | ||
|
||
console.log(myMap.has("bar")); // true | ||
console.log(myMap.has("baz")); // false | ||
``` | ||
|
||
## 명세서 | ||
|
||
{{Specifications}} | ||
|
||
## 브라우저 호환성 | ||
|
||
{{Compat}} | ||
|
||
## 같이 보기 | ||
|
||
- {{jsxref("Map")}} | ||
- {{jsxref("Map.prototype.set()")}} | ||
- {{jsxref("Map.prototype.get()")}} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요! @wisedog 님. 다음 문장에 대한 번역 제안을 드립니다.
Note that the map holding a reference to the original object effectively means the object cannot be garbage-collected, which may lead to unexpected memory issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
중간에 끊은건 좋은 제안입니다.
다만 제안주신 내용 중 아래 내용을 한 번 살펴보시면 어떨까 합니다.
(제안주신 내용) -> (다시 제안드리는 내용)
오브젝트 -> 해당 객체
가비지 콜렉팅 -> 가비지 콜렉션 혹은 쓰레기 수집
메모리 이슈 -> 메모리 문제
독자가 이해하는데 크게 문제 없으면 영어보다는 한글로 적고자 합니다만, 가비지 콜렉팅은... 현업에서는 전자를 주로 쓰긴하던데 쓰려면 가비지 콜렉션으로 하던가 쓰레기 수집이 좋지 않을까 싶습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 제안 주신 부분 모두 좋습니다 :) 자주 사용하는 표현을 반영하여 쓰레기 수집보다는 가비지 콜렉션이 어떨까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 알겠습니다. 좋은 리뷰 감사합니다!