Skip to content

Instantly share code, notes, and snippets.

Created February 8, 2020 18:36
What would you like to do?
let re = /a/g
re.test('ab') // returns true
re.test('ab') // this will fail! re.lastIndex === 1 so it starts searching at 'b'
re.test('ab') // this will pass! since it failed, re.lastIndex is reset to 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment