JavaScript 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.

  • JavaScript arrays have a very robust API offering a plethora of amazing tools. Learn the 4 must-know JavaScript array methods in this quick guide.

  • Regular expressions, while very powerful, are notoriously hard to master. Start using them in your JavaScript code by understanding these 6 features.

  • Accessibility (a11y) can improve your website and attract new users. Learn how to get started with these 8 quick tips.

  • accumulate

    JavaScript, Math

    Creates an array of partial sums.

  • addClass

    JavaScript, Browser

    Adds a class to an HTML element.

  • addDaysToDate

    JavaScript, Date

    Calculates the date of n days from the given date, returning its string representation.

  • addMinutesToDate

    JavaScript, Date

    Calculates the date of n minutes from the given date, returning its string representation.

  • addMultipleListeners

    JavaScript, Browser

    Adds multiple event listeners with the same handler to an element.

  • addStyles

    JavaScript, Browser

    Adds the provided styles to the given element.

  • addWeekDays

    JavaScript, Date

    Calculates the date after adding the given number of business days.

  • all

    JavaScript, Array

    Checks if the provided predicate function returns true for all elements in a collection.

  • allEqual

    JavaScript, Array

    Checks if all elements in an array are equal.

  • allEqualBy

    JavaScript, Array

    Checks if all elements in an array are equal, based on the provided mapping function.

  • allUnique

    JavaScript, Array

    Checks if all elements in an array are unique.

  • allUniqueBy

    JavaScript, Array

    Checks if all elements in an array are unique, based on the provided mapping function.