How to display Javascript codes on an html page

You need to convert your < and > characters in JavaScript to HTML entities &lt and &gt (less than and greater than).


For instance, the Javascript code is:

<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
obj.employees[1].firstName + " " + obj.employees[1].lastName;
</script>

You need to convert the < and > characters in JavaScript to HTML entities &lt and &gt:

 &ltp id="demo"&gt 
 &lt/p&gt 
<br />    
&ltscript&gt
    document.getElementById("demo").innerHTML =
    obj.employees[1].firstName + " " + obj.employees[1].lastName;<br />
&lt/script&gt