What I'm wondering is; is there a simpler syntatic shortcut to what I'm trying to do here.
I have one large JSON object during a loop, like so:
let line = {
first_name: ...,
last_name: ...,
title: ...,
email: ...,
facebook_account: ...,
linkedin_account: ...,
twitter_account: ...,
instagram_account: ...,
snapchat_account: ...
};
I then break this payload down into smaller objects:
let profile = {
first_name: line.first_name,
last_name: line.last_name,
title: line.title,
email: line.email
};
let social = {
facebook_account: line.facebook_account,
linkedin_account: line.linkedin_account,
twitter_account: line.twitter_account,
instagram_account: line.instagram_account,
snapchat_account: line.snapchat_account
};
Does ES6 afford me a way to cut the repetition of each property i.e. first_name, facebook_account, etc.? The property names are not necessarily obvious in regards to how they get broken down - it's based on our data model.
This is a lot of manual work w/ a lot of repetition. I wonder if I'm missing some piece of ES6 magic, or something, that'd pretty this up. I'm not really looking for a super clever recursive loop with a machine learning algorithm...just shorter syntax, if possible. :)