Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"abc".match( RegExp.prototype ) gives an error #1398

Open
GabrielLidenor opened this issue Jan 1, 2019 · 0 comments
Open

"abc".match( RegExp.prototype ) gives an error #1398

GabrielLidenor opened this issue Jan 1, 2019 · 0 comments

Comments

@GabrielLidenor
Copy link

When you call "abc".match( RegExp.prototype ) the console will give an error: Method RegExp.prototype.exec called on incompatible receiver [object Object]

To avoid this, you need to convert RegExp.prototype to a String, like this:

"abc".match( RegExp.prototype.toString() ); \\null

which returns null because the match method could not find any string with the pattern of "/(?:)/".

When match finds something it will return an Array Object, for example: "abc".match(/ab/); returns ["ab"];

PR #1397

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants