Lodash setWith
Takes in an Object, a path, and an arbitrary value to set, using the given path as the key.
js
import { setWith } from "lodash";
const user = { name: "Arn" };
// Now user is { name: "Arn", favoriteFruit: "Arnana" }
setWith(user, "favoriteFruit", "Arnana");
WARNING
If using lodash/fp
, this function has a custom argument order of (d, b, c, a)
.