I'm not a JS wizard but I guess it is the equivalent to SQL injection.
The string is not being treated strictly as text. Instead it tries to execute whatever you put inside the parenthesis
I'm not a JS wizard but I guess it is the equivalent to SQL injection.
The string is not being treated strictly as text. Instead it tries to execute whatever you put inside the parenthesis
kek
>It will evaluate as true no matter what
No it won't. It will return the right hand side. If the strings don't match, find2 will be null, so the assignment will actually be falsey.
So it'll kind of work, for really stupid reasons
>So it'll kind of work, for really stupid reasons
This is like the motto of JavaScript.
I figured something like that was the culprit. What I'm trying to do is capture the first line in the first textarea, then use that result in a .match on the whole text in the second textare. So if there is an exact match anywhere in the second textarea, it should match it.
I figured if I used .toStrong on the result of the .match on the first textarea, it would convert the matched text to a string and use it to perform the .match..
.toString
Sorry for the typo
That's a misuse of match. Use .includes instead
The first match should also probably be str.split('\n')[0] instead of str.match(/.+/), but whatever
Just because it works for your case doesn't mean it's not wrong. The correct way to do comparison is always with ===.
As for the parenthesis thing, the console seems to complain about unterminated parentheticals. I'm not sure why it's performing a syntax check on arbitrary input strings.
It's also the motto of my adventures in JavaScript so far. As you can probably see, I conjured this straight out of my own imagination with my limited self-taught JavaScript skills.
see .match expects a regular expression, and will try to compile its input into a regular expression if it's a string. An invalid regular expression will cause it to throw.