[javascript] Appending to an object

I'm sorry but i can't comment your answers already due my reputation!...so, if you wanna modify the structure of your object, you must do like Thane Plummer says, but a little trick if you do not care where to put the item: it will be inserted on first position if you don't specify the number for the insertion.

This is wonderful if you want to pass a Json object for instance to a mongoDB function call and insert a new key inside the conditions you receive. In this case I gonna insert a item myUid with some info from a variable inside my code:

_x000D_
_x000D_
// From backend or anywhere_x000D_
let myUid = { _id: 'userid128344'};_x000D_
// .._x000D_
// .._x000D_
_x000D_
  let myrequest = { _id: '5d8c94a9f629620ea54ccaea'};_x000D_
  const answer = findWithUid( myrequest).exec();_x000D_
_x000D_
// .._x000D_
// .._x000D_
_x000D_
function findWithUid( conditions) {_x000D_
  const cond_uid = Object.assign({uid: myUid}, conditions);_x000D_
  // the object cond_uid now is:_x000D_
  // {uid: 'userid128344', _id: '5d8c94a9f629620ea54ccaea'}_x000D_
  // so you can pass the new object Json completly with the new key_x000D_
  return myModel.find(cond_uid).exec();_x000D_
}
_x000D_
_x000D_
_x000D_