Skip to content Skip to sidebar Skip to footer

What Does The "return" Do In "return Myfunction()"

On the Moz Dev Network, it give an example of using onchanged like this: What is the difference between the ab

Solution 1:

This will return result of your myFunction() invoking. In your case if this will return Boolean value this will change or not <textarea> content.

Read more about Function's at MDN and onchange element property.

Solution 2:

When you return something from a function, that value gets returned to the caller. For instance, say I had a method to multiply two numbers. Maybe the code looks like this:

functionmultiply(num1, num2) {
return num1 * num2;
}
result = multiply(2, 4);

The function multiply will return the result of it's multiplication to wherever it was called. The right-hand side of the result assignment is where the function is called, so that is where the result is returned to. So, in this case (with the parameters 2 and 4), it is the same as writing result = 8;

When you are using return true or false with markup, you are indicating whether or not you want the default action to happen after the javascript has been executed.

Solution 3:

From this Reference Link

Sets or retrieves a Boolean value that indicates whether the current event is canceled.When an event is canceled, the default action that belongs to the event will not be executed. For example, when the onclick event (the onclick event is cancelable) is canceled for a checkbox, then clicking on the checkbox does not change its checked state.

Use of return value is to prevent default event handler to execute based on the Boolean return value.Not every event can be canceled. You can use return when you when you want that on some condition you want to prevent default event execution. For example : onclick event of submit button of form if you return false it will prevent form to submit and if you return true it will continue submit from.

Post a Comment for "What Does The "return" Do In "return Myfunction()""