I would like to remove an element from an array that is inside an object and override that object with the new values. See example below.
var obj = {
a: [1, 2, 3],
b: [4, 5, 6],
c: [7, 8, 9]
}
I would like to remove the number 5 from obj without knowing in which array the element is.
I am trying to update a state in react using the Context API. It should directly return the object itself.
case ACTION: return {
...state,
obj: ?
}
Expected final result :
var obj = {
a: [1, 2, 3],
b: [4, 6],
c: [7, 8, 9]
}
react, are you using this with state? If so the answer is different as you don't want to mutate the array directly.reactinside a Context