2 Example(s) of JavaScript special characters


Description :

JavaScript has lots of special characters like \b,\t, \n, \v, \f, \", \' etc and In this example we will see how to use single quotes and double quotes in JavaScript. See the code snippet:


JavaScript special characters Example - 1
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>   
<body>
<p id="sample"></p>
<script>
var x = 'It\'s alright';
var y = "Image Path is \"C:\" from the MyComputer.";
document.getElementById("sample").innerHTML = x + "<br>" + y; 

</script>

</body>
</html>

Output

Description :

This is how we use special character double quotes in string "Hello \" Welcome to LEARNKODE\"."; See the code snippet:


JavaScript special characters Example - 2
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>   
<body>
<p id="sample"></p>
<script>
document.getElementById("sample").innerHTML = "Hello \" Welcome to LEARNKODE\".";
</script>

</body>
</html>

Output