Object syntax or destructuring?

by Benny Neugebauer

user_et.provider_id = data.service.provider;
user_et.service_id =;

const {provider: provider_id, id: service_id} = data.service
user_et.provider_id = provider_id;
user_et.service_id = service_id;

Why the snake case?

Anyway, both examples are weird, and I would avoid mutating existing objects if possible. I prefer reconstructing the original object with the changes, so every new line involves a new const

const { provider, id } = data.service

const user_et = {


  provider_id: provider,

  service_id: id,


Tim Buckley

Sign in to comment!