JavaScript function declaration

前端 未结 8 921
别那么骄傲
别那么骄傲 2021-01-30 04:49

Are the JavaScript code snippets given below some sort of function declaration? If not can someone please give an overview of what they are?

some_func = function         


        
8条回答
  •  自闭症患者
    2021-01-30 04:56

    One way of doing it:

    var some_func = function(value) {  
        // some code here
    }
    

    Another way:

    function some_funct() {
    }
    

    Yet another way:

    var some_object={};
    some_object["some_func"] = function() {};
    

    or:

    var some_object={};
    some_object.some_func = function() {};
    

    In other words, they are many ways to declare a function in JS.


    Your second example is not correct.

提交回复
热议问题