Comment on Ask HN: What problem can I help you with?parentComments−LecroJS4yMaybe I’m misunderstanding the problem but any reason why you can’t just call .map on the input array and if el.name === John -> el.hobby[knitting] = true, then return el regardless?−adamredwoods4yYou could if the object was a known structure, but I needed a function that could be a utility for any object (some were quite large), something like:const newobj = insertIntoObject( obj, ["name:John", "hobby:*"], newdata )
Comments
Maybe I’m misunderstanding the problem but any reason why you can’t just call .map on the input array and if el.name === John -> el.hobby[knitting] = true, then return el regardless?
You could if the object was a known structure, but I needed a function that could be a utility for any object (some were quite large), something like:
const newobj = insertIntoObject( obj, ["name:John", "hobby:*"], newdata )