JSON Modify an Array Value of a JSON Object Last Updated : 21 Jun, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The arrays in JSON (JavaScript Object Notation) are similar to arrays in JavaScript. Arrays in JSON can have values of the following types: nullbooleannumberstringarrayobject The arrays in JavaScript can have all these but it can also have other valid JavaScript expressions which are not allowed in JSON. The array value of a JSON object can be modified. It can be simply done by modifying the value present at a given index. Example: Modifying the value present at an index in the array JavaScript let myObj, i; myObj = { // Stored the values "words": ["I", "am", "Good"] }; // Modifying the value present at index 2 myObj.words[2] = "bad"; for (i in myObj.words) { // Displaying the modified content console.log(myObj.words[i]); } OutputI am bad Note: If the value is modified at an index that is out of the array size, then the new modification will not replace anything in the original information but rather will be an add-on. Example: Modifying the value of the index which is out of the array size. JavaScript let myObj, i; myObj = { // Stored the values "words": ["I", "am", "Good"] }; // Modifying the value present at index 2 myObj.words[3] = "bad"; for (i in myObj.words) { // Displaying the modified content console.log(myObj.words[i]); } OutputI am Good bad Comment More infoAdvertise with us Next Article JSON Modify an Array Value of a JSON Object GeeksforGeeks Improve Article Tags : JavaScript Similar Reads JavaScript - Convert an Array to an Object Here are some common methods which can be used to convert an array to an object: 1. Using JavaScript Object.assign() method The first approach is using the Object.assign() method. This method copies the values of all enumerable properties from source objects(one or more) to a target object.JavaScrip 3 min read JavaScript- Add an Object to JS Array In JavaScript, arrays are used to store multiple values in a single variable, and objects are collections of properties and values. Sometimes, we may need to add an object to an array to manage data more effectively. These are the following ways to add an object to a JS array: Using JavaScript Array 4 min read How to Move a Key in an Array of Objects using JavaScript? The JavaScript array of objects is a type of array that contains JavaScript objects as its elements.You can move or add a key to these types of arrays using the below methods in JavaScript:Table of ContentUsing Object Destructuring and Map()Using forEach() methodUsing for...of LoopUsing reduce() met 5 min read How to modify an object's property in an array of objects in JavaScript ? To modify an objectâs property in an array of objects, you can use methods like forEach(), map(), or find() to locate the object and then modify its properties. Here are some methods to modify an object's property in an array of objects:1. Using the Array.map() methodThe map() method returns a new a 4 min read How to Swap Array Object Values in JavaScript ? We have given the array of objects, and our task is to swap the values of the object keys present in the array of objects. Below is an example for a better understanding of the problem statement. Example:Input: arr = [{a: 1, b: 2}, {a:3, b: 4}]Output: [ { a: 2, b: 1 }, { a: 4, b: 3 } ]Explnation: Th 4 min read Like