and

Performs a logical AND operation on the given arguments.

1. Code

/**
 * Performs a logical AND operation on the given boolean values.
 * Returns true if all arguments are true, otherwise returns false.
 *
 * @param args - The boolean values to perform the AND operation on.
 * @returns The result of the logical AND operation.
 */
const and = (...args: any[]) => {
  if (args.length === 0) return false;
  return args.every((arg) => Boolean(arg));
};

export default and;

2. Installation

npx @jrtilak/lazykit@latest add and -undefined

3. Description

The and function is a utility function in TypeScript that performs a logical AND operation on the given arguments.

4. Props

Prop

Type

Default Value

args*any[]---

5. Examples

import and from ".";

console.log(and(true, true));
// Expected Output: true

console.log(and(true, false));
// Expected Output: false

console.log(and());
// Expected Output: true

console.log(and(1, "lazykit"));
// Expected Output: true