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.

  • Delay async function execution

    Delays the execution of an asynchronous function.

    JavaScript, Function · Oct 22, 2020

  • Is JavaScript pass-by-value or pass-by-reference?

    How JavaScript handles passing data is a source of confusion and bugs for many developers, especially when it comes to object types.

    JavaScript, Function · Dec 5, 2021

  • Tip: The order of then and catch matters

    Messing up the order of chained then and catch methods in JavaScript promises can result in all sorts of problems. Here's a short primer on the subject.

    JavaScript, Function · Jun 12, 2021

  • Flip function arguments

    Takes a function as an argument, then makes the first argument the last.

    JavaScript, Function · Jun 13, 2021

  • Value is async function

    Checks if the given argument is an async function.

    JavaScript, Type · Oct 20, 2020

  • Value is generator function

    Checks if the given argument is a generator function.

    JavaScript, Type · Oct 20, 2020

  • JavaScript function methods - call(), apply() and bind()

    Learn everything you need to know about JavaScript's Function.prototype.call(), Function.prototype.apply() and Function.prototype.bind() with this short guide.

    JavaScript, Function · Jun 12, 2021

  • What is recursion and when is it useful?

    Recursion is a very important programming concept all developers should be familiar with.

    JavaScript, Function · Jan 23, 2022

  • Prepend function arguments

    Creates a function that invokes fn with partials prepended to the arguments it receives.

    JavaScript, Function · Sep 15, 2020

  • Append function arguments

    Creates a function that invokes fn with partials appended to the arguments it receives.

    JavaScript, Function · Sep 15, 2020

  • Delay function execution

    Invokes the provided function after ms milliseconds.

    JavaScript, Function · Oct 19, 2020

  • Generate items

    Generates an array with the given amount of items, using the given function.

    JavaScript, Array · Oct 22, 2020

  • Range generator

    Creates a generator, that generates all values in the given range using the given step.

    JavaScript, Function · Oct 11, 2020

  • Tip: Abort a fetch request in JavaScript

    Aborting a fetch request in JavaScript is a common problem. Here's how to handle it correctly.

    JavaScript, Function · May 15, 2022

  • Curry function

    Curries a function.

    JavaScript, Function · Oct 22, 2020