HOME        MAIN

JavaScript Built-in Functions: Examples


MAIN        TOP

eval()

<SCRIPT LANGUAGE="JavaScript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS

document.writeln("eval(\"5 + 3\") =" + eval("5 + 3") + "<BR>");
document.writeln("eval(\"'5' + 3\") =" + eval("'5' + 3") + "<BR>");
document.writeln("eval(\"'Hello ' + 'World'\") =" + eval("'Hello ' + 'World'") + "<BR>");
document.writeln("eval(\"'ten is ' + 10\") =" + eval("'ten is ' + 10") + "<BR>");

// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</SCRIPT>


Output:


MAIN        TOP

isFinite()

<SCRIPT LANGUAGE="JavaScript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS

document.writeln("Number.MAX_VALUE=" + Number.MAX_VALUE + "<BR>");
document.writeln("isFinite(Number.MAX_VALUE)=" + isFinite(Number.MAX_VALUE) + "<BR>");
document.writeln("Number.MAX_VALUE+1.0e292=" + (Number.MAX_VALUE + 1.0e292) + "<BR>");
document.writeln("isFinite(Number.MAX_VALUE+1.0e292)=" + isFinite(Number.MAX_VALUE + 1.0e292) + "<BR>");

// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</SCRIPT>


Output:


MAIN        TOP

isNaN()

<SCRIPT LANGUAGE="JavaScript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS

document.writeln("Number.NaN=" + Number.NaN + "<BR>");
document.writeln("isNaN(Number.NaN)=" + isNaN(Number.NaN) + "<BR>");
document.writeln("isNaN('ten' + 5)=" + isNaN('ten' + 5) + "<BR>");
document.writeln("isNaN('10' + 5)=" + isNaN('10' + 5) + "<BR>");
document.writeln("isNaN(Number.MAX_VALUE)=" + isNaN(Number.MAX_VALUE) + "<BR>");
document.writeln("isNaN(Number.POSITIVE_INFINITY)=" + isNaN(Number.POSITIVE_INFINITY) + "<BR>");

// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</SCRIPT>


Output:


MAIN        TOP

parseInt()

<SCRIPT LANGUAGE="JavaScript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS

a = "100"
document.writeln("a=\"" + a + "\"<BR>");
document.writeln("parseInt(a)=" + parseInt(a) + "<BR>");
document.writeln("parseInt(a, 2)=" + parseInt(a, 2) + "<BR>");
document.writeln("parseInt(a, 8)=" + parseInt(a, 8) + "<BR>");
document.writeln("parseInt(a, 16)=" + parseInt(a, 16) + "<BR>");
a = "100.0"
document.writeln("a=\"" + a + "\"<BR>");
document.writeln("parseInt(a)=" + parseInt(a) + "<BR>");
document.writeln("parseInt(a, 2)=" + parseInt(a, 2) + "<BR>");
document.writeln("parseInt(a, 8)=" + parseInt(a, 8) + "<BR>");
document.writeln("parseInt(a, 16)=" + parseInt(a, 16) + "<BR>");
a = "100.0e2"
document.writeln("a=\"" + a + "\"<BR>");
document.writeln("parseInt(a)=" + parseInt(a) + "<BR>");
document.writeln("parseInt(a, 2)=" + parseInt(a, 2) + "<BR>");
document.writeln("parseInt(a, 8)=" + parseInt(a, 8) + "<BR>");
document.writeln("parseInt(a, 16)=" + parseInt(a, 16) + "<BR>");
a = "10A"
document.writeln("a=\"" + a + "\"<BR>");
document.writeln("parseInt(a)=" + parseInt(a) + "<BR>");
document.writeln("parseInt(a, 2)=" + parseInt(a, 2) + "<BR>");
document.writeln("parseInt(a, 8)=" + parseInt(a, 8) + "<BR>");
document.writeln("parseInt(a, 16)=" + parseInt(a, 16) + "<BR>");
a = "A10"
document.writeln("a=\"" + a + "\"<BR>");
document.writeln("parseInt(a)=" + parseInt(a) + "<BR>");
document.writeln("parseInt(a, 2)=" + parseInt(a, 2) + "<BR>");
document.writeln("parseInt(a, 8)=" + parseInt(a, 8) + "<BR>");
document.writeln("parseInt(a, 16)=" + parseInt(a, 16) + "<BR>");

// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</SCRIPT>


Output:


MAIN        TOP

parseFloat()

<SCRIPT LANGUAGE="JavaScript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS

a = "100"
document.writeln("a=\"" + a + "\"<BR>");
document.writeln("parseFloat(a)=" + parseFloat(a) + "<BR>");
a = "100.5"
document.writeln("a=\"" + a + "\"<BR>");
document.writeln("parseFloat(a)=" + parseFloat(a) + "<BR>");
a = "100.5e2"
document.writeln("a=\"" + a + "\"<BR>");
document.writeln("parseFloat(a)=" + parseFloat(a) + "<BR>");
a = "A100.5"
document.writeln("a=\"" + a + "\"<BR>");
document.writeln("parseFloat(a)=" + parseFloat(a) + "<BR>");

// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</SCRIPT>


Output:


MAIN        TOP
Hosted by www.Geocities.ws

1