---
title: "Discussion on \"Add items to an array in Nunjucks\" | Hashnode"
description: "Discussion on \"Add items to an array in Nunjucks\". To add items in Nunjucks, use the .push() function.\n  {% set arr = [1,2] %}\n  {% set arr = (arr.push(3), arr) %}\n\nFinal array:\narr = [1,2,3]\n\nUnfortunately, I did not found any references in the official Nunjucks documentation for this useful functio..."
url: "https://hashnode.com/posts/add-items-to-an-array-in-nunjucks/600872c777d8da2629c94680"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Add items to an array in Nunjucks](https://giuliachiola.hashnode.dev/add-items-to-an-array-in-nunjucks?utm_source=hashnode&utm_medium=feed)

To add items in Nunjucks, use the .push() function. {% set arr = \[1,2\] %} {% set arr = (arr.push(3), arr) %} Final array: arr = \[1,2,3\] Unfortunately, I did not found any references in the official Nunjucks documentation for this useful functio...

Jan 20, 2021 · 1 min read · giuliachiola.hashnode.dev  
Updated Aug 22, 2022  
Read the article

## Written by

[Giulia Chiola](https://hashnode.com/@giuliachiola)

@giuliachiola · Val di Susa, Italia

  
[View profile](https://hashnode.com/@giuliachiola)

Front-end Developer. 👾 Media engineer. ⚡ Facing life one bug at a time. 🔥 Easily bribed with chocolate. 🍫 she/her

Front-end Developer. 👾 Media engineer. ⚡ Facing life one bug at a time. 🔥 Easily bribed with chocolate. 🍫 she/her - #BLM

## Responses 1

Markdown supported · ⌘↵ to post

[Manjunatha Kaliyur](https://hashnode.com/@kgm)

[Dec 9, 2021](https://hashnode.com/posts/add-items-to-an-array-in-nunjucks/600872c777d8da2629c94680/comment/61b1f1a06a81cf6b31dfc202)

TY. Found this after trying to accomplish this exact same feature. This is really useful.

[Giulia Chiola](https://hashnode.com/@giuliachiola)

[Jan 18, 2022](https://hashnode.com/posts/add-items-to-an-array-in-nunjucks/600872c777d8da2629c94680/comment/61b1f1a06a81cf6b31dfc202#reply-61e72c406f4d6f431978be57)

Glad this post was useful! 😊
