Skip to content

filterInvalidValues

filterInvalidValues(obj): Record<string, unknown>

过滤对象中的无效值

过滤对象数据中的 undefined、null 和空字符串

Parameters

NameTypeDescription
objRecord<string, unknown>要过滤的对象

Returns

Record<string, unknown>

过滤后的对象

Example

ts
filterInvalidValues({
  name: 'John',
  age: 30,
  email: '',
  phone: null,
  address: undefined
});
// 返回 { name: 'John', age: 30 }

Released under the MIT License.