Advertisement
sissou123

Untitled

Mar 16th, 2022
1,082
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. JavaScript Algorithms and Data Structures
  2. Basic JavaScript
  3. Escaping Literal Quotes in Strings
  4. When you are defining a string you must start and end with a single or double quote. What happens when you need a literal quote: " or ' inside of your string?
  5.  
  6. In JavaScript, you can escape a quote from considering it as an end of string quote by placing a backslash (\) in front of the quote.
  7.  
  8. const sampleStr = "Alan said, \"Peter is learning JavaScript\".";
  9. This signals to JavaScript that the following quote is not the end of the string, but should instead appear inside the string. So if you were to print this to the console, you would get:
  10.  
  11. Alan said, "Peter is learning JavaScript".
  12. for more:http://besturl.link/fQLiYE5V
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement