how to update value in nested json using id in javascript
function getObjects(obj, key, val, newVal) {
var newValue = newVal;
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val, newValue));
} else if (i == key && obj[key] == val) {
obj[key] = 'qwe';
}
}
return obj;
}
function getObjects(obj, key, val, newVal) {
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (i == key && obj[key] == val) {
obj[key] = newVal;
}
}
return obj
}
Also in JavaScript:
- google apps script lock service
- cant find variable react
- jquery ajax on fail
- extension for local storage in angular 8
- how to use flatlist keyextractor
- javascript every other element in array
- hot loading react native shortcut key
- axios Cross origin http://localhost forbidden
- ES6: Set Default Parameters for Your Functions
- javascript assign
- this.setstate is not a function in react native
- javascript get attribute
- javascript example of foreach loop
- Checking whether a value exists in an array javascript
- javascript custom events with data
- $(document).on in javascript
- JSONDecoder
- javascript string first letter lowercase
- if touchend javascript
- react detect finger
- using this to get name of the clicked element
- react case switch not working
- how to update json key name while keeping the values in mysql
- how to make a div appear when clicked on in javascript