Skip to content

Commit b6a5f13

Browse files
committed
[번역추가] Part1 5.4 배열
1 parent ff947c3 commit b6a5f13

1 file changed

Lines changed: 19 additions & 18 deletions

File tree

1-js/05-data-types/04-array/article.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,38 +92,38 @@ let fruits = [
9292
trailing(길게 늘어지는) 쉼표를 사용하면 모든 줄의 생김새가 유사해지기 때문에 요소를 넣거나 빼기가 쉬워집니다.
9393
````
9494

95-
## Get last elements with "at"
95+
## "at"으로 마지막 요소 가져오기
9696

9797
[recent browser="new"]
9898

99-
Let's say we want the last element of the array.
99+
배열의 마지막 요소를 가져오고 싶다고 가정해 봅시다.
100100

101-
Some programming languages allow the use of negative indexes for the same purpose, like `fruits[-1]`.
101+
일부 프로그래밍 언어에서는 `fruits[-1]`처럼 음수 인덱스를 사용해 마지막 요소에 접근할 수 있습니다.
102102

103-
However, in JavaScript it won't work. The result will be `undefined`, because the index in square brackets is treated literally.
103+
하지만 자바스크립트에서는 `fruits[-1]`처럼 음수 인덱스를 사용해도 원하는 결과를 얻을 수 없습니다. 대괄호 안의 인덱스를 문자 그대로 해석하기 때문에 결과는 `undefined`가 됩니다.
104104

105-
We can explicitly calculate the last element index and then access it: `fruits[fruits.length - 1]`.
105+
따라서 `fruits[fruits.length-1]`처럼 마지막 요소의 인덱스를 직접 계산해서 접근해야 합니다.
106106

107107
```js run
108-
let fruits = ["Apple", "Orange", "Plum"];
108+
let fruits = ["사과", "오렌지", "자두"];
109109

110-
alert( fruits[fruits.length-1] ); // Plum
110+
alert( fruits[fruits.length-1] ); // 자두
111111
```
112112

113-
A bit cumbersome, isn't it? We need to write the variable name twice.
113+
조금 번거롭지 않은가요? 변수 이름을 두 번이나 작성해야 합니다.
114114

115-
Luckily, there's a shorter syntax: `fruits.at(-1)`:
115+
다행히 더 짧은 문법인 `fruits.at(-1)`이 있습니다.
116116

117117
```js run
118-
let fruits = ["Apple", "Orange", "Plum"];
118+
let fruits = ["사과", "오렌지", "자두"];
119119

120-
// same as fruits[fruits.length-1]
121-
alert( fruits.at(-1) ); // Plum
120+
// fruits[fruits.length-1]와 동일
121+
alert( fruits.at(-1) ); // 자두
122122
```
123123

124-
In other words, `arr.at(i)`:
125-
- is exactly the same as `arr[i]`, if `i >= 0`.
126-
- for negative values of `i`, it steps back from the end of the array.
124+
즉, `arr.at(i)`는 다음과 같이 동작합니다. In other words, `arr.at(i)`:
125+
- `i>=0`이면 `arr[i]`와 완전히 동일하게 동작합니다.
126+
- `i`가 음수이면 배열 끝에서부터 거슬러 올라가며 요소를 찾습니다.
127127

128128
## pop·push와 shift·unshift
129129

@@ -170,7 +170,7 @@ In other words, `arr.at(i)`:
170170
alert( fruits ); // 사과,오렌지
171171
```
172172

173-
Both `fruits.pop()` and `fruits.at(-1)` return the last element of the array, but `fruits.pop()` also modifies the array by removing it.
173+
`fruits.pop()``fruits.at(-1)`은 모두 배열의 마지막 요소를 반환합니다. 하지만 `fruits.pop()`은 마지막 요소를 반환하는 동시에 배열에서 제거하기 때문에 배열 자체도 변경한다는 차이가 있습니다.
174174

175175
`push`
176176
: 배열 끝에 요소를 추가합니다.
@@ -468,9 +468,10 @@ alert( "1,2" + 1 ); // "1,21"
468468
`==`는 배열을 특별하게 취급하지 않습니다. 배열도 일반 객체처럼 처리됩니다.
469469

470470
규칙을 다시 떠올려 봅시다.
471+
471472
- 두 객체는 동일한 객체를 참조할 때만 `==` 비교 결과가 `true`입니다.
472473
- `==`의 피연산자 중 하나가 객체이고 다른 하나가 원시값이면, <info:object-toprimitive> 챕터에서 설명한 것처럼 객체가 원시값으로 변환됩니다.
473-
- 단, `null``undefined`는 예외입니다. 서로에 대해서만 `==` 비교 시 `true`를 반환하고 그 외의 값과 비교했을 때는 `false`를 반환합니다.
474+
- 단, `null``undefined`는 예외입니다. 서로에 대해서만 `==` 비교 시 `true`를 반환하고 그 외의 값과 비교할 때는 `false`를 반환합니다.
474475

475476
엄격한 비교 연산자 `===`는 더 단순합니다. 타입 변환을 수행하지 않기 때문입니다.
476477

@@ -547,4 +548,4 @@ let arr = new Array(item1, item2...);
547548

548549
대신 `for..of` 반복문을 사용해 배열 요소를 하나씩 비교할 수 있습니다.
549550

550-
<info:array-methods> 챕터에선 배열에 요소를 더하거나 빼기, 원하는 요소를 추출하기, 배열 정렬하기 등과 관련된 다양한 메서드를 학습할 예정입니다.
551+
<info:array-methods> 챕터에선 배열에 요소를 더하거나 빼기, 원하는 요소를 추출하기, 배열 정렬하기 등과 관련된 다양한 메서드를 학습할 예정입니다.

0 commit comments

Comments
 (0)