JavaScript Builtin Functions

JavaScript Built-in Functions
JavaScript Built-in Functions

A function is a piece of code that performs some operations on variables to fulfill a specific task. It takes
one or more input values, processes them, and returns an output value. JavaScript provides built-in functions that
are already defined to fulfill a certain task.

Lists the built-in functions.

Function Description Example
alert() Displays a dialog box
some information and OK
alert(“Please fill all the field of the form”);
Displays a message box with the instruction.
confirm() Displays a dialog box
with OK and Cancel buttons.It verifies an action,
which a user wants to perform
confirm(“Are you sure you want to close the page?”);
Displays a message box with the question.
parseInt() Convert a string value into
a numeric value
parseFloat() Convert a string into a
numv=ber with decimal point
parseFloat(“10.33”);Return 10.33
eval() Evaluates an expression and
returns the evaluated result
eval(“2+2”);Return 4
isNaN() Checks whether a value is
not a number
isNaN(“Hello”);Returns true
prompt() Displays a dialog box that
accepts an input value
through a text box. It also
accepts the default value
for the text box
prompt(“Enter your name”,”Name”);
Displays the message in the dialog box
and Name in the text box.

Demonstrates the use of some of the built-in functions in JavaScript. It performs the addition operation JavaScript.

      <title> JavaScript Language </title>
      function myFunction(a,b)
      return a*b;
       var a,b;
          a=parseInt(prompt("enter a variable", a ));
            b=parseInt(prompt("enter a variable" , b));
           alert("product is " + myFunction(a,b));

In the code, it takes the first value from the user and stores in the numone variable. Then, it takes the second
value from the user and stores in the numtwo variable. It multiplies the values and stores the output in the result
variable and then displays the output on the Web page.


Please enter your comment!
Please enter your name here