How to compare two regexps? January 1, 2024 by Tarik Try this: String(regexp1) === String(regexp2)) You are getting false because those two are different objects.