JavaScript Logical Operations

Boolean logic and logical operations might not come up that often in JavaScript development, but when they do, you'll be glad you know how to use them. This small collection of snippets can help you get started.

  • Apply function when condition is met

    Returns a function that takes one argument and runs a callback if it's truthy or returns it if falsy.

    JavaScript, Function · Oct 22, 2020

  • Logical or for functions

    Checks if at least one function returns true for a given set of arguments.

    JavaScript, Function · Oct 19, 2020

  • Logical complement

    Returns a function that is the logical complement of the given function, fn.

    JavaScript, Function · Sep 15, 2020