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

  • Hex to RGB

    Converts a color code to an rgb() or rgba() string if alpha value is provided.

    JavaScript, String · Oct 19, 2020

  • String is anagram

    Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).

    JavaScript, String · Oct 20, 2020

  • How to construct a URL in JavaScript

    A short guide on how to correctly construct a URL in JavaScript.

    JavaScript, String · Feb 26, 2023

  • Regular Expressions Cheat Sheet

    Regular expressions are a very useful tool in a variety of situations. Save this cheatsheet for any time you need to look up their syntax and speed up your development.

    JavaScript, String · Jun 12, 2021

  • Array to CSV

    Converts a 2D array to a comma-separated values (CSV) string.

    JavaScript, Array · Nov 3, 2020

  • Kebabcase string

    Converts a string to kebab case.

    JavaScript, String · Dec 16, 2020

  • Palindrome

    Checks if the given string is a palindrome.

    JavaScript, String · Oct 22, 2020

  • Reverse number

    Reverses a number.

    JavaScript, Math · Sep 18, 2020

  • Sort characters in string

    Alphabetically sorts the characters in a string.

    JavaScript, String · Oct 22, 2020

  • HSL to array

    Converts an hsl() color string to an array of values.

    JavaScript, String · Oct 22, 2020

  • RGB to array

    Converts an rgb() color string to an array of values.

    JavaScript, String · Jun 13, 2021

  • String to words

    Converts a given string into an array of words.

    JavaScript, String · Oct 22, 2020

  • Tip: Edit URL Parameters in JavaScript

    Avoid the naive approach and use a more robust method to edit URL parameters in JavaScript.

    JavaScript, String · Dec 7, 2022

  • Decapitalize string

    Decapitalizes the first letter of a string.

    JavaScript, String · Nov 1, 2020

  • Reverse string

    Reverses a string.

    JavaScript, String · Oct 18, 2020