In JavaScript there are a lot of characters/symbols that we may want to display in the
web browser that simply
are not on the keyboard such as ™, ►, → ,
© and
®. Fortunately, in
HTML there is a way
to reproduce these special characters without resorting to the use of an image. By placing an
ampersand followed by the number symbol, followed by a valid number and a semi colon
we can
produce the
HTML character list. The following example will demonstrate this as well a an
incremental counter that will output the numbers 32-254 and place that number between
signs available on each keyboard;
to output the main special JavaScript Reserve Characters for display.
<html>
<head><title>JavaScript Tutorial</title></head>
<body>
<table width="100%">
<tr class="tblHead">
<td><b>Character Entity Number</b></td>
<td><b>Out put</b></td>
<td><b>Character Entity Number</b></td>
<td><b>Out put</b></td>
</tr>
<tr class="simple">
<script language="JavaScript">
<!--
var c = 0;
var cl = 0;
for(var count=32; count<=254; count++)
{
if (cl==0){
cls ="formated";
cl=1;
}else{
cls ="simple";
cl=0;
}
if (c<2){
document.write("<td>&#");
document.write(count + ";");
document.write("</td><td>&#" + count + ";</td>");
c++;
}else{
document.write("</tr>");
document.write("<tr class=" + cls + ">");
c=0;
}
}
// -->
</script>
</table>
</body>
</html>
JavaScript is very heavy handed in its restrictions on reserved key words. The
reserved JavaScript key words list is as under
abstract
boolean break byte
case catch char class const continue
debugger default delete do double
else enum export extends
false final finally float for function
goto
if implements import in instanceof int interface
long
native new null
package private protected public
return
short static super switch synchronized
this throw throws transient true try typeof
var volatile void
while with
Most of those words are not even used in the JavaScript language. A reserved word cannot
be used...
- As a name in literal object notation
in JavaScript
- As a member name in dot notation
in JavaScript
- As a function argument
of JavaScript
- As a var
Variable in JavaScript
- As an unqualified global JavaScript variable
- As a statement label of JavaScript
There is no excuse for the first two restrictions in JavaScript. None. There is an excuse
for the second two restrictions, but it is very weak.
Escape characters in JavaScript are used inside literal
JavaScript strings to allow print formatting as
well as preventing certain JavaScript characters from causing interpretation
JavaScript errors. Each
JavaScript escape character starts with a backslash. The available JavaScript character sequences list
for Escape characters are as under.