Fri, 19th Feb 2021, 09:45

TIL calling RegExp.prototype.test multiple times can return different results when the regex is a global one. 🤯

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test

![](/images/media/Screenshot 2021-02-19 at 10.39.27.png)

RegExp.prototype.test() - JavaScript | MDNThis API has not been standardized.This API has not been standardized.This API has not been standardized.This API has not been standardized.This API has not been standardized.This API has not been standardized.This deprecated API should no longer be used, but will probably still work.This API has not been standardized.This is an obsolete API and is no longer guaranteed to work.This deprecated API should no longer be used, but will probably still work.This deprecated API should no longer be used, but will probably still work.This API has not been standardized.This API has not been standardized.This is an obsolete API and is no longer guaranteed to work.This deprecated API should no longer be used, but will probably still work.This deprecated API should no longer be used, but will probably still work.This deprecated API should no longer be used, but will probably still work.This deprecated API should no longer be used, but will probably still work.This deprecated API should no longer be used, but will probably still work.This API has not been standardized.This is an obsolete API and is no longer guaranteed to work.

The test() method executes a search for a match between a regular expression and a specified string. Returns true or false.

developer.mozilla.org

Comments