I am new to JavaScript, so I am reading some JavaScript code (for Google Earth Engine) and I got confused. I have some code that looks like the following pseudo code:
function function_0(some_existing_object_from_elsewhere, further_argument) {
// What happened to these computing since they are not included in the returned dictionnary?
some_existing_object_from_elsewhere = some_function(some_existing_object_from_elsewhere)
further_argument = further_argument === undefined ? 0 : further_argument
// return a dictionnary of function
return {
function_1: function_1,
function_2: function_2
}
function function_1(args) {
some Code
return something
}
function function_2(args) {
some Code
// call to function_0. This is the most confusing. How the call to function_0 can be explained here?
return function_0(some_existing_object_from_elsewhere, further_argument)
}
}
My questions are:
What happens to the dictionary of functions returned here? Are these functions added to
some_existing_object_from_elsewhere
as additional methods?What happens to the computation before
return
since they are not included in the returned dictionary?How does the call to
function_0
works insidefunction_0
itself whilefunction_0
isn't really some sort-of recursive function? Then, what doesfunction_2
returns, the originalsome_existing_object_from_elsewhere
or the processedsome_existing_object_from_elsewhere
as returned bysome_function(some_existing_object_from_elsewhere)
?
Overall, I am very confused. Any explanation and/or points to further reading would be helpful. Feel free to extend your explanations to other related aspects not captured in my questions.