What is the optimized way to clone one object from another object with specific properties, not all?
Like below we can get values by projection from an object:
let tempObject = { prop1 : 'something', prop2 : 'something' , other : 'others' }; //then let { prop1, prop2} = tempObject; Same way I want to clone a few properties from another object like
let oldObject = { p1 : 'something', p2 : 'somethig', p3 : 'something' } Want to make another object from above oldObject with only p1 and p2 those two properties. Expected newObject will be {p1 : 'something', p2 : 'somethig'}.
I know there are many ways to do that but I wanted to know the optimized way with the explanation.