Does return callback to function or console.log()?


#1

When using return within a function, where is this information being stored?


#2

nowhere, its the programmers job to handle the returned information

For example we can store the returned result in a variable:

var example = function(){
    return "Hello world!"
}
x = example();

now the returned string is stored in x variable

we can also log the returned string to the console:

var example = function(){
    return "Hello world!"
}
console.log(example());

or we can do both:

var example = function(){
    return "Hello world!"
}
x = example();
console.log(x);

if we need to the string later and need to log it the console

now of course, these functions are really simply. They serve as an example of possibilities which is important to understand once functions grow more complex


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.