0

Writing a regular expression, I found this code:

JSON.stringify(e.model.ProcedureDate).replace(/\"/g, '');

Why does /\"/g work without being quoted? It isn't a string, and from what I gather, javascript doesn't have literals... What would you call the text passed to .replace()?

2

2 Answers 2

2

It is a regular expression literal, equivalent to:

new RegExp('\\"', 'g')

in the same way as [] is equivalent to new Array(0).

Sign up to request clarification or add additional context in comments.

Comments

2

Javascript has regular expression literals. That's an example of one.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.