If I have an object called userData = {..}
and I need to create another object, userDataB, with properties a, b, c, and d from userData but only if they are defined. One way to achieve this is by using the following approach:
userDataB = {}
if(userData.a){userDataB.a = a};
if(userData.b){userDataB.b = b};
...
Is there a cleaner way to accomplish this task, perhaps leveraging ES5 or ES6 features?