apphouse
Version:
Component library for React that uses observable state management and theme-able components.
39 lines (38 loc) • 1.04 kB
TypeScript
/**
* creates a new object (newObj) by copying all the properties from the original
* object using the spread operator ({ ...obj }). Then, it iterates over each
* key in keysToOmit using forEach, and deletes those keys from the newObj
* using the delete keyword.
* @param obj the original object
* @param keysToOmit the keys to omit
* @returns a new object (newObj) that includes all properties of the original object
* except the ones specified in keysToOmit.
*
*
* @example
* For example, let's say you have an object like this:
*
* ```javascript
* const originalObject = {
* name: 'John',
* age: 25,
* city: 'New York',
* country: 'USA'
* };
* ```
*
* To omit the `name` and `age` keys, you can use the `omit` function like this:
*
* ```javascript
* const newObj = omit(originalObject, ['name', 'age']);
*
* console.log(newObj);
* ```
*
* The output will be:
*
* ```javascript
* { city: 'New York', country: 'USA' }
* ```
*/
export declare function omit<T>(obj: T, keysToOmit: string[]): T;