Skip to content

Commit

Permalink
docs(first): Update example (#712)
Browse files Browse the repository at this point in the history
  • Loading branch information
mass2527 authored Oct 14, 2024
1 parent dbc3ca3 commit 3ed5a41
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 9 deletions.
22 changes: 19 additions & 3 deletions docs/ja/reference/compat/array/first.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,23 @@ function first<T>(arr: ArrayLike<T> | undefined | null): T | undefined;
##

```typescript
const emptyArr: number[] = [];
const noElement = head(emptyArr);
// noElement will be undefined
const arr1 = [1, 2, 3];
const firstElement1 = first(arr1);
// firstElement1は1です。

const arr2: string[] = [];
const firstElement2 = first(arr2);
// firstElement2はundefinedです。

const arr3 = ['a', 'b', 'c'];
const firstElement3 = first(arr3);
// firstElement3は'a'です。

const arr4 = [true, false, true];
const firstElement4 = first(arr4);
// firstElement4はtrueです。

const arr5: [number, string, boolean] = [1, 'a', true];
const firstElement5 = first(arr5);
// firstElement5は1です。
```
22 changes: 19 additions & 3 deletions docs/reference/compat/array/first.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,23 @@ function first<T>(arr: ArrayLike<T> | undefined | null): T | undefined;
## Examples

```typescript
const emptyArr: number[] = [];
const noElement = head(emptyArr);
// noElement will be undefined
const arr1 = [1, 2, 3];
const firstElement1 = first(arr1);
// firstElement1 will be 1

const arr2: string[] = [];
const firstElement2 = first(arr2);
// firstElement2 will be undefined

const arr3 = ['a', 'b', 'c'];
const firstElement3 = first(arr3);
// firstElement3 will be 'a'

const arr4 = [true, false, true];
const firstElement4 = first(arr4);
// firstElement4 will be true

const arr5: [number, string, boolean] = [1, 'a', true];
const firstElement5 = first(arr5);
// firstElement5 will be 1
```
22 changes: 19 additions & 3 deletions docs/zh_hans/reference/compat/array/first.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,23 @@ function first<T>(arr: ArrayLike<T> | undefined | null): T | undefined;
## 示例

```typescript
const emptyArr: number[] = [];
const noElement = head(emptyArr);
// noElement will be undefined
const arr1 = [1, 2, 3];
const firstElement1 = first(arr1);
// firstElement1 将是 1

const arr2: string[] = [];
const firstElement2 = first(arr2);
// firstElement2 将是 undefined

const arr3 = ['a', 'b', 'c'];
const firstElement3 = first(arr3);
// firstElement3 将是 'a'

const arr4 = [true, false, true];
const firstElement4 = first(arr4);
// firstElement4 将是 true

const arr5: [number, string, boolean] = [1, 'a', true];
const firstElement5 = first(arr5);
// firstElement5 将是 1
```

0 comments on commit 3ed5a41

Please sign in to comment.