1) Javascript function does not have to return anything. 2) Even if some Javascript function always returns something, the particular type of return may not be defined; generally, Javascript uses
dynamic typing paradigm:
http://en.wikipedia.org/wiki/JavaScript#Dynamic[
^].
This may need some additional explanation: "types are associated with values, not variables". Even the same very function, depending, say, on parameters passed, may return different things of different type of not return anything at all, which will cause assignment of
undefined object. What "type", for example, will be returned by the function shown below? Try to determine it:
function whoKnowsWhat(input) {
if (input != 3)
return input;
}
someVariable = whoKnowsWhat(3);
someVariable = whoKnowsWhat("some string");
someVariable = whoKnowsWhat(12);
In this example, the function will return object of different types and assign them to the same variable. In first case, nothing is returned, so this means leaving the variable unassigned.
—SA