If the value passed is a not a number, the boolean value of true is returned, if it is a number, it returns false.
<script type="text/javascript">
document.write(isNaN(123) + "
"); // false
document.write(isNaN(5 - 2) + "
"); // false
document.write(isNaN(0) + "
"); // false
document.write(isNaN("Hello") + "
"); // true
</script>
Converts a string to integer or float value. It can also evaluate expressions included with a string.
<script type="text/javascript">
eval("x=10;y=20;document.write(x*y)"); // 200
document.write("
" + eval("2+2")); // 4
document.write("
" + eval(x + 7)); // 17
</script>
Converts a string to an integer returning the first integer encountered in string.if not found then returns NaN.
<script type="text/javascript">
document.write(parseInt("10") + "
"); // 10
document.write(parseInt("10.33") + "
");// 10
</script>
Converts a string to an float returning the first float encountered in string.if not found then returns NaN
<script type="text/javascript">
document.write(parseFloat("123") + "
"); // 123
document.write(parseFloat(true) + "
"); // NaN
</script>
Converts an object to String.
<script type="text/javascript">
document.write(String(1234)+ "
"); // 1234
document.write(String(1234.56)+ "
"); // 1234.56
document.write(String(true)+ "
"); // true
</script >
Converts an object to Number.
<script type="text/javascript">
document.write(Number("1234")+ "
"); // 1234
document.write(Number(new Boolean(true))+ "
"); // 1
document.write(Number("333,55")+ "
"); // NaN
</script>
Displays a Alert dialog box with a message.
Displays a box with the message passed to the function displayed. The user can then enter text in the prompt field, and choose OK or Cancel. If the user chooses Cancel, a NULL value is returned. If the user chooses OK, the string value entered in the field is returned.
<script type="text/javascript">
var name = prompt("Please Enter Your Name");
if (name != '') {
alert(name);
}
</script>
When called, it will display the message and two buttons. One is "OK" and the other is "Cancel". If OK is selected, a value of true is returned, otherwise a value of false is returned.
<script type="text/javascript">
var h=confirm("Do you want see 'HI' ?");
if(h){
alert("hi");
}
</script>
| After editing Click here: |
Output:
|