Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Javascript () Operator Invokes the Function

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 97
    Comment on it

    Javascript () Operator Invokes the Function

    During the call of the function the code of the function gets executed. the call to the function can be made by the name of the function followed by the parentheses ().

    example:

    func(1,2);
    

    This parentheses works as an operator to invoke the function to pass the values to the function. Also indicates to execute the statements of the function body. A function call without parentheses () always return the function definition.

    This example to show a function call using () operator which performs an addition.

    <!DOCTYPE html>
    <html>
    <body>
    <p id="demo"></p>
    <script>
    function add(a, b) {
        return a + b;
    }
    document.getElementById("demo").innerHTML = add(4, 3);
    </script>
    
    </body>
    </html>
    

    Output:

    7

    This example to show a function call without using () operator.

    <!DOCTYPE html>
    <html>
    <body>
    <p id="demo"></p>
    <script>
    function add(a, b) {
        return a + b;
    }
    document.getElementById("demo").innerHTML = add;
    </script>
    
    </body>
    </html>
    

    Output:

    function add(a, b) { return a + b; }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: