isNaN() :

If the value passed is a not a number, the boolean value of true is returned, if it is a number, it returns false.

Example :
                    <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>

eval() :

Converts a string to integer or float value. It can also evaluate expressions included with a string.

Example :
                    <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>

parseInt() :

Converts a string to an integer returning the first integer encountered in string.if not found then returns NaN.

Example :
                    <script type="text/javascript">
                        document.write(parseInt("10") + "
"); // 10 document.write(parseInt("10.33") + "
");// 10 </script>

parseFloat() :

Converts a string to an float returning the first float encountered in string.if not found then returns NaN

Example :
                    <script type="text/javascript">
                        document.write(parseFloat("123") + "
"); // 123 document.write(parseFloat(true) + "
"); // NaN </script>

String() :

Converts an object to String.

Example :
<script type="text/javascript">
    document.write(String(1234)+ "
"); // 1234 document.write(String(1234.56)+ "
"); // 1234.56 document.write(String(true)+ "
"); // true </script >

Number() :

Converts an object to Number.

Example :
<script type="text/javascript">
    document.write(Number("1234")+ "
"); // 1234 document.write(Number(new Boolean(true))+ "
"); // 1 document.write(Number("333,55")+ "
"); // NaN </script>

Dialoag Boxes :

alert() :

Displays a Alert dialog box with a message.

prompt(msg) :

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.

Example :
                    <script type="text/javascript">
                        var name = prompt("Please Enter Your Name");
                        if (name != '') {
                            alert(name);
                        }
                    </script>
                

confirm(msg) :

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.

Example :
                    <script type="text/javascript">
                            var h=confirm("Do you want see 'HI' ?");
                            if(h){
                                alert("hi");
                                }
                    </script>
                
Exercises :
  1. Write the code to take first name and last name in prompt and display as full name.
  2. Write a code to take two numbers and take the operator. Evaluate and show the result in alert box.
After editing Click here:
Output: