what the global flag does depends on method: with match() if you don’t use global flag it will return just first match, if you use global flag it will return all matches
don’t use global flag with other methods before checking documentation on that method