Summary of the most basic statements of function functions in JavaScript

function declaration

function sum(num1,num2){

return num1+num2;

}

function expression

var sum=function(num1,num2){

return num1+num2;

};

return statement in a function

A return statement can have no return value, in this case: return; or without a return statement in the function, the function will return a value after execution has stopped. This usage is generally required to stop the function execution early without returning a value.

return false to prevent the element's default event.

return returns the return value of its function.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324481623&siteId=291194637