Functions inside objects

后端 未结 2 1980
渐次进展
渐次进展 2020-12-14 15:52

I know the title is vague but I didn\'t know what to write.
In javascript, I know how to write functions that will be called like this :

argument1.func         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-14 16:25

    you need to define the objects like this :

    var argument1 = {
        myvar : "12",
        mymethod : function(test) { return something; }
    }
    

    then call mymethod like:

    argument1.mymethod(parameter);
    

    or the deeper version :

    var argument1 = {
        argument2 : {
           mymethod : function(test) { return something; }
        }
    } 
    

    then:

    argument1.argument2.mymethod(parameter);
    

提交回复
热议问题