Clone RegExp

JavaScript, Type · Oct 22, 2020

Clones a regular expression.

const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags);
const regExp = /lorem ipsum/gi;
const regExp2 = cloneRegExp(regExp); // regExp !== regExp2

More like this

  • Collection is empty

    Checks if the a value is an empty object/collection, has no enumerable properties or is any type that is not considered a collection.

    JavaScript, Type · Oct 20, 2020

  • Value is promise-like

    Checks if an object looks like a Promise.

    JavaScript, Type · Oct 20, 2020

  • Value is async function

    Checks if the given argument is an async function.

    JavaScript, Type · Oct 20, 2020