---
title: append – เพิ่มค่าต่อท้ายอาร์เรย์
url: https://www.thepexcel.com/functions/n8n/array-functions/append-n8n/
type: function-explainer
program: n8n
syntax: array.append(value)
date: 2025-12-16
updated: 2025-12-17
scores:
  popularity: 7
  difficulty: 2
  usefulness: 7
---

# append – เพิ่มค่าต่อท้ายอาร์เรย์

> เพิ่มค่าต่อท้ายอาร์เรย์ (คืนค่าอาร์เรย์ใหม่)

## คำอธิบาย

append() เป็น n8n-specific array extension (ไม่ใช่ JavaScript method มาตรฐาน) เพิ่มค่าหรือรายการใหม่ต่อท้ายอาร์เรย์ คืนค่าเป็นอาร์เรย์ใหม่ (immutable - ไม่แก้ไขอาร์เรย์เดิม) มีประโยชน์ในการเพิ่มรายการใหม่ รวมข้อมูลจากหลายแหล่ง หรือสร้างอาร์เรย์แบบ incremental

## Syntax

```excel
array.append(value)
```

**Variant**

```excel
$json.items.append(newItem)
```

เพิ่ม item ใหม่ต่อท้าย array

**Variant**

```excel
$json.tasks.append({ id: 4, name: 'New Task' })
```

เพิ่ม object ใหม่ต่อท้าย

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| value | Yes | any |  | ค่าที่ต้องการเพิ่มต่อท้ายอาร์เรย์ (สามารถเป็น string, number, object, หรือ array ก็ได้) |

## เคสการใช้งาน

### เพิ่มรายการใหม่จาก API

เพิ่มข้อมูลใหม่ที่รับจาก API call ต่อท้ายอาร์เรย์ที่มีอยู่

_เหมาะกับ:_ data-accumulation

### รวมข้อมูลจากหลายแหล่ง

เพิ่มรายการจากแหล่งข้อมูลต่างๆ เข้าด้วยกันเป็นอาร์เรย์เดียว

_เหมาะกับ:_ data-aggregation

### สร้าง log entries

เพิ่ม log entry ใหม่ต่อท้าย log array สำหรับ tracking

_เหมาะกับ:_ logging

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: เพิ่มตัวเลขต่อท้าย

```excel
{{ [1, 2, 3].append(4) }}
```

**ผลลัพธ์:** `[1, 2, 3, 4]`

เพิ่ม 4 ต่อท้าย [1, 2, 3] ได้ [1, 2, 3, 4]

### 2. ตัวอย่างที่ 2: เพิ่ม object ต่อท้าย

```excel
{{ [{ id: 1, name: 'John' }, { id: 2, name: 'Jane' }].append({ id: 3, name: 'Bob' }) }}
```

**ผลลัพธ์:** `[{ id: 1, name: 'John' }, { id: 2, name: 'Jane' }, { id: 3, name: 'Bob' }]`

เพิ่ม object ใหม่ต่อท้าย array of objects

### 3. ตัวอย่างที่ 3: เพิ่มรายการลงในอาร์เรย์ว่าง

```excel
{{ [].append('first item') }}
```

**ผลลัพธ์:** `['first item']`

เพิ่ม 'first item' ลงในอาร์เรย์ว่าง สร้างอาร์เรย์ใหม่ที่มี 1 รายการ

### 4. ตัวอย่างที่ 4: Chain multiple append

```excel
{{ [1, 2].append(3).append(4).append(5) }}
```

**ผลลัพธ์:** `[1, 2, 3, 4, 5]`

Chain หลาย append() เพื่อเพิ่มหลายค่าต่อท้าย ได้ [1, 2, 3, 4, 5]

## หมายเหตุเพิ่มเติม

⚠️ append() เป็น n8n-specific extension ไม่ใช่ JavaScript method มาตรฐาน คืนค่าอาร์เรย์ใหม่ (immutable) เพิ่มทีละ 1 ค่า ถ้าต้องการรวม arrays ใช้ concat() แทน สามารถ chain หลาย append() ได้

## คำถามที่พบบ่อย

**Q: append() กับ push() ต่างกันอย่างไร?**

append() คืนค่าอาร์เรย์ใหม่ (immutable, ไม่แก้ไขอาร์เรย์เดิม) ส่วน push() แก้ไขอาร์เรย์เดิมโดยตรง (mutable) ใน n8n ส่วนใหญ่ใช้ append() เพราะรักษา immutability ของ expressions

**Q: append() รองรับการเพิ่มหลายค่าพร้อมกันหรือไม่?**

ไม่ append() เพิ่มทีละ 1 ค่า ถ้าต้องการเพิ่มหลายค่าใช้ chain: array.append(1).append(2).append(3) หรือใช้ concat() เพื่อรวม 2 arrays: [1,2].concat([3,4,5])

**Q: append() กับ concat() ต่างกันอย่างไร?**

append() เพิ่มค่าเดียว (เช่น item หรือ array as single element) ส่วน concat() รวม arrays (flatten elements) เช่น [1,2].append([3,4]) ได้ [1,2,[3,4]] แต่ [1,2].concat([3,4]) ได้ [1,2,3,4]

**Q: ใช้ append() เมื่อไหร่?**

ใช้เมื่อต้องการเพิ่มรายการเดียวต่อท้ายอาร์เรย์ เช่น เพิ่มข้อมูลใหม่จาก API สร้าง log entries หรือรวมรายการจากหลายแหล่ง ใช้ concat() แทนถ้าต้องการรวม arrays ใช้ push() ถ้าต้องการแก้ไขอาร์เรย์เดิม (ไม่แนะนำใน n8n)

## ฟังก์ชันที่เกี่ยวข้อง

- [concat – ฟังก์ชันต่อข้อความหลาย ๆ ตัว](https://www.thepexcel.com/functions/n8n/string-functions/concat-n8n/)
- [first() – ดึงสมาชิกตัวแรกจากอาร์เรย์](https://www.thepexcel.com/functions/n8n/array-functions/first-n8n/)
- [last – ดึงสมาชิกตัวสุดท้ายจากอาร์เรย์](https://www.thepexcel.com/functions/n8n/array-functions/last-n8n/)
- push-n8n

---

_Source: [https://www.thepexcel.com/functions/n8n/array-functions/append-n8n/](https://www.thepexcel.com/functions/n8n/array-functions/append-n8n/)_
