JavaScript Function Snippets

The JavaScript snippet collection contains a wide variety of ES6 helper functions. It includes helpers for dealing with primitives, arrays and objects, as well as algorithms, DOM manipulation functions and Node.js utilities.

  • complement

    JavaScript, Function

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

  • either

    JavaScript, Function

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

  • functionName

    JavaScript, Function

    Logs the name of a function.

  • negate

    JavaScript, Function

    Negates a predicate function.

  • timeTaken

    JavaScript, Function

    Measures the time it takes for a function to execute.

  • unary

    JavaScript, Function

    Creates a function that accepts up to one argument, ignoring any additional arguments.

  • when

    JavaScript, Function

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