Skip to content

Instantly share code, notes, and snippets.

@juanigaray
Created April 6, 2020 15:50
Show Gist options
  • Save juanigaray/1d174cac2b40f20b9e477456b2a79bc0 to your computer and use it in GitHub Desktop.
Save juanigaray/1d174cac2b40f20b9e477456b2a79bc0 to your computer and use it in GitHub Desktop.
Lodash set nested value in array
// You can test this here: https://codepen.io/travist/full/jrBjBz/
var users = [
{ user: 'barney', age: 36, active: true },
{ user: 'fred', age: 40, active: false },
{ user: 'travis', age: 37, active: true}
];
result = _.set(users, "0.user", "asd");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment