Creates a new object by omitting specified properties from the original object.
function omit<T extends object, K extends string | number | symbol>( instance: T, keys: K[]): Omit<TK>Omit<T, K>Creates a new object by omitting specified properties from the original object.
TK[]Omit<T, K>Creates a new object by omitting specified properties from the original object.
This function returns a new object that contains all properties from the original
object except for the ones specified in the keys parameter.
const user = { id: 1, name: 'John', email: '[email protected]', password: 'secret' };
const publicUser = omit(user, ['password']);
// Result: { id: 1, name: 'John', email: '[email protected]' }
const user = { id: 1, name: 'John', email: '[email protected]', password: 'secret' };
const basicUser = omit(user, ['password', 'email']);
// Result: { id: 1, name: 'John' }
