What is it for / Text / in Javascript

Asked

Viewed 38 times

1

I was seeing if there was another kind of comment in Java besides the // or /* */. That’s when I realized, when I took out the asterisk of /* */ did not return an error, returned exactly what I had written, which in case was / OI /. I looked it up and couldn’t find what it’s for. Does anyone know?

1 answer

2

What you wrote was a regular expression, as exemplified by the @hkotsubo comment on the question. Anything between / / will be interpreted as a regular expression in Javascript, such as /[0-9]/g to find all the digits that can vary between 0 and 9 within a given string, for example.

I hope I’ve helped in some way.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.