copyOnly
Method is NOT in-place. Also, compatible to call with Array
Definition
function copyOnly(...keys: string[]) : object;
Example
This one is pretty straightforward... You can provide a list of keys or only single key to copy from an object to a new object
import '@marthvon/protopp';
// or
import '@marthvon/protopp/objectpp/methods/copyOnly.js';
const o = { a: 1, b: 2, c: 3, d: 4 };
console.log(o.copyOnly('a'));
// Outputs { a: 1 }
console.log(o.copyOnly('b', 'c'));
// Outputs { b: 2, c: 3 }
console.log(o.copyOnly('a', 'c', 'd'));
// Outputs { a: 1, c: 3, d: 4 }