@resk/core
Version:
An innovative TypeScript framework that empowers developers to build applications with a fully decorator-based architecture for efficient resource management. By combining the power of decorators with a resource-oriented design, DecorRes enhances code cla
19 lines (18 loc) • 1.06 kB
TypeScript
/**
* Returns the first non-null and non-undefined value among the provided arguments.
*
* This function takes a variable number of arguments and returns the first one that is not null or undefined.
* It iterates through the arguments and checks each one. If a non-null and non-undefined value is found, it is returned immediately.
* If no non-null and non-undefined value is found, but a null value is found, null is returned. Otherwise, undefined is returned.
*
* @param {...any[]} args The values to check for a non-null and non-undefined value.
* @returns {any} The first non-null and non-undefined value found, or null if a null value is found, or undefined if no value is found.
* @example
* ```typescript
* console.log(defaultVal("hello", null, "world")); // Output: "hello"
* console.log(defaultVal(null, null, "world")); // Output: "world"
* console.log(defaultVal(null, null, null)); // Output: null
* console.log(defaultVal(undefined, undefined)); // Output: undefined
* ```
*/
export default function defaultVal(...args: any[]): any;