Executes a function only if the condition is false.
This is an inverse of an if statement, providing a concise way to execute logic only if the condition is not met.
Parameters
cond: boolean
The condition to check.
fn: ()=>void
The function to execute if the condition is false.
Returns void
Example
// Will log "Access denied" because the condition is false unless(user.isAdmin, () =>console.log("Access denied"));
Example
// Will not log anything because the condition is true unless(user.isAdmin, () =>console.log("Access denied"));
Executes a function only if the condition is
false. This is an inverse of anifstatement, providing a concise way to execute logic only if the condition is not met.