How to Get a Value from a JSON Array in JavaScript? Last Updated : 28 Jun, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report To retrieve a value from a JSON array in JavaScript, we can use various methods such as accessing the array by index or using built-in methods like find(), map(), etc.1. Accessing Values by IndexIn a JSON array, values are stored in an ordered list, which means you can directly access a value by its index.Syntax:arr[index];arr: The JSON array.index: The position of the item you want to access. JavaScript let a = [ { "name": "Sourav", "age": 23 }, { "name": "Ajay", "age": 25 } ]; let val = a[0].name; console.log(val); OutputSourav In this example:arr[0] accesses the first object in the array..name accesses the name property of that object.The output will be "Sourav", the value of the name property in the first object.2. Using the find() MethodThe find() method allows you to find an object within a JSON array based on a condition.Syntax:arr.find(callback);arr: The JSON array.callback: A function that tests each element of the array. The find() method returns the first element that satisfies the condition in the callback. JavaScript let a = [ { "name": "Sourav", "age": 23 }, { "name": "Ajay", "age": 25 } ]; let person = a.find(item => item.name === "Ajay"); console.log(person.age); Output25 3. Using map() MethodThe map() method is useful when you need to retrieve values from a property of each object in the array.Syntax:arr.map(callback); JavaScript let a = [ { "name": "Sourav", "age": 23 }, { "name": "Ajay", "age": 25 } ]; let names = a.map(item => item.name); console.log(names); Output[ 'Sourav', 'Ajay' ] In this exampleThe map() method iterates through each object in the array.For each object, it returns the name property, which results in a new array ["Sourav", "John"].4. Using forEach() MethodThe forEach() method is used to iterate through each element of the array and access the values.Syntax:arr.forEach(callback); JavaScript let a = [ { "name": "Sourav", "age": 23 }, { "name": "Ajay", "age": 25 } ]; a.forEach(item => { if (item.name === "Sourav") { console.log(item.age); } }); Output23 In this example:The forEach() method iterates through each object in the array.For each object, it checks if the name property is "Sourav". If true, it logs the age property.5. Using filter() MethodIf you need to retrieve multiple values based on a condition, you can use the filter() method.Syntax:arr.filter(callback); JavaScript let a = [ { "name": "Sourav", "age": 23 }, { "name": "Ajay", "age": 25 }, { "name": "Sourav", "age": 30 } ]; let res = a.filter(item => item.name === "Sourav"); console.log(res); Output[ { name: 'Sourav', age: 23 }, { name: 'Sourav', age: 30 } ] In this exampleThe filter() method returns all objects in the array where the name property is "Sourav".In this case, two objects match, and the result is an array containing both objects. Comment More infoAdvertise with us Next Article How to use forEach with an Array of Objects in JavaScript ? Y yajasvikhqmsg Follow Improve Article Tags : JavaScript Web Technologies javascript-array JSON Similar Reads How to get Values from Specific Objects an Array in JavaScript ? In JavaScript, an array is a data structure that can hold a collection of values, which can be of any data type, including numbers, strings, and objects. When an array contains objects, it is called an array of objects. Table of Content Using the forEach() methodUsing the map() methodUsing the filte 2 min read How to Convert JSON to ArrayBuffer in JavaScript? An ArrayBuffer is a complex data type, and structures which has a fixed length and takes binary content as the whole. Any variable that contains pure binary data will be defined in JavaScript as Simple Data, however on some occasions it is sometimes necessary to convert JSON data to an ArrayBuffer, 4 min read How to get a key in a JavaScript object by its value ? To get a key in a JavaScript object by its value means finding the key associated with a specific value in an object. Given an object with key-value pairs, you want to identify which key corresponds to a particular value, often for searching or data retrieval.How to get a key in a JavaScript object 4 min read How to use forEach with an Array of Objects in JavaScript ? Using the forEach() method with an array of objects in JavaScript is essential for iterating over collections and performing operations on each object. This guide explores effective techniques to utilize forEach() for array manipulation, enhancing your coding skills. Syntax: array.forEach( function( 3 min read How to get the Value by a Key in JavaScript Map? JavaScript Map is a powerful data structure that provides a convenient way to store key-value pairs and retrieve values based on keys. This can be especially useful when we need to associate specific data with unique identifiers or keys.Different Approaches to Get the Value by a Key in JavaScript Ma 3 min read How to Convert Object to Array in JavaScript? In this article, we will learn how to convert an Object to an Array in JavaScript. Given an object, the task is to convert an object to an Array in JavaScript. Objects and Arrays are two fundamental data structures. Sometimes, it's necessary to convert an object to an array for various reasons, such 4 min read Like