Question : strings are enclosed in double quotation marks while string literals are enclosed in single quotation marks.
Answered by : richard-john
Single-Quoted strings: While using single-quoted strings for defining string literals, we only need to escape the single quote inside the string. While there is no need to escape double-quote and can be written exactly
<script> const geeks = 'We will visit \'GeeksforGeeks\' student.'; const hello = 'Hello, I am an "Engineer"'; document.write(geeks + "<br>"); document.write(hello)
</script>
While using double-quoted strings for defining string literals, we only need to escape the double-quote inside the string. While there is no need to escape single-quote and can be written exactly
<script> const geeks = "We will visit \"GeeksforGeeks\" student." const hello = "Hello, I am an 'Engineer'" document.write(geeks+"<br>") document.write(hello)
</script>
Source : https://www.geeksforgeeks.or | Last Update : Wed, 31 Aug 22