Menu Close
    Hire us Request quote Reading list Switch to dark mode
    lockdownWebkulUp

    Declaring Function ( in JavaScript )

    What is Function?

    Function are the small chunks of modules designed to work for a specific task or purpose. Functions that we define for single purpose are easy to debug and use.These functions when defined for single purpose can be used again in future. Most programming languages come with a prewritten set of functions that are kept in a library. You can also write your own functions to perform specialized tasks.

    You can see below I have defined how these functions can be declared in javascript below :-

    Regular Function

    A function is declared with function keyword, function name and parameters.
    Here function is a keyword used to declare function, then followed by function name ( myFunc ) and inside parenthesis we have variables (parameter_1, parameter_2) whose value will be passed while declaration.


    Anonymous function

    A function that has no name of itself and are declared with function keyword are called Anonymous function.
    These functions can be stored in a variable and are always invoked (called) using the variable name in which function is stored.

    . . .
    Subscribe Articles

    Just enter your email below to subscribe and receive weekly updates about the most interesting similar articles.

    You need to accept conditions to receive letters.
    You've Subscribed!

    Share article via

    . . .


    Function() Constructor

    These are the functions that we can declare with a built-in JavaScript function constructor.
    We have to use Function keyword to declare a function in this type of function.


    Self-Invoking Function

    When you want to invoke a function without being called then you can use Self-Invoking Functions as they are invoked (started) automatically, without being called.
    The only requirement is that it should be ended with ().


     

    That’s all for today on how to declare functions in JavaScript, if you still have issues feel free to comment below for any query.

    . . .

    Comment

    Add Your Comment

    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close