---
title: "Discussion on \"Add Element to Array just if It Doesn’t Exist in the Array\" | Hashnode"
description: "Discussion on \"Add Element to Array just if It Doesn’t Exist in the Array\". In JavaScript, how to add an element to an array just if it does not yet exist within the given array?"
url: "https://hashnode.com/posts/javascript-add-to-array-if-not-exist/64822d20fb9a6535b7c52b70"
---

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

Discussion

# [Add Element to Array just if It Doesn’t Exist in the Array](https://mayallo.hashnode.dev/javascript-add-to-array-if-not-exist?utm_source=hashnode&utm_medium=feed)

In JavaScript, how to add an element to an array just if it does not yet exist within the given array?

Jun 8, 2023 · 4 min read · mayallo.hashnode.dev  
Updated Jun 15, 2023  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#beginners](https://hashnode.com/tag/beginners)
-   [#beginner](https://hashnode.com/tag/beginner)
-   [#array](https://hashnode.com/tag/array)
-   [#coding](https://hashnode.com/tag/coding)

## Written by

[Mohamed Mayallo](https://hashnode.com/@mayallo)

@mayallo

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

Self-taught Software Engineer

I'm a Software Engineer Passionate about Clean Code, Design Patterns, and System Design. Learning something new every day. Feel free to say Hi on LinkedIn at https://www.linkedin.com/in/mayallo

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
