---
title: "Discussion on \"Push associative array into array in JavaScript\" | Hashnode"
description: "Discussion on \"Push associative array into array in JavaScript\". let myArray = [];\n\nfunction insert(key, value) {\n  let obj = {};\n  obj[key] = value;\n  myArray.push(obj);\n}\n\ninsert(\"name\", \"John\");\ninsert(\"age\", 30);\ninsert(\"city\", \"New York\");\n\nconsole.log(myArray);\n\nIn this example, we declare an empty array cal..."
url: "https://hashnode.com/posts/push-associative-array-into-array-in-javascript/6421992380c40aee9ebcd872"
---

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

Discussion

# [Push associative array into array in JavaScript](https://blog.qodesign.net/push-associative-array-into-array-in-javascript?utm_source=hashnode&utm_medium=feed)

let myArray = \[\]; function insert(key, value) { let obj = {}; obj\[key\] = value; myArray.push(obj); } insert("name", "John"); insert("age", 30); insert("city", "New York"); console.log(myArray); In this example, we declare an empty array cal...

Mar 27, 2023 · 3 min read · blog.qodesign.net  
Read the article

-   [#js](https://hashnode.com/tag/js)
-   [#associative-arrays](https://hashnode.com/tag/associative-arrays)
-   [#jquery](https://hashnode.com/tag/jquery)

## Written by

[Rk Mahbub](https://hashnode.com/@rkmahbub)

@rkmahbub

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

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
