<> The return value of the function

give an example :
function sum(a,b){ return a + b;
return The purpose of this is to end the method .

be careful :

* return The following value will be returned as the result of the function , You can define a variable , To receive the result ;
* in function return The following statements will not be executed ( Function at the end of execution return Statement and exit immediately );
* If return Statement does not follow any value , It's like returning one undefined;
* The return value can be any data type , It can be an object , It can be a function .
<> Function name , Function body and function loading problem

We have to remember : Function name == Entire function , give an example :
console.log(fn) == console.log(function fn(){ alert(1) } ); // definition fn method function
fn(){ alert(1) };
When a function is called , Function names are usually used () This format ; But at this point , We use the function format directly , His function is equivalent to the whole function .
Loading problem of function :JS When loading , Load function name only , Do not load function body , So if you want to use an internal variable member , The function needs to be called .

<>fn() and fn The difference between

* fn(): Call function , It is equivalent to getting the return value of the function .
* fn : Function object , It is equivalent to obtaining the function object directly .
<> Execute function immediately

The existing anonymous functions are as follows :
function(a,b){ document.write("a=" + a); document.write("b = " + b); };
Immediately execute the function as follows :
(function(a,b){ document.write("a=" + a); document.write("b = " + b); })(123,
456);
The results are as follows :

Execute function immediately : End of function definition , Called immediately , This kind of function is called immediate execution function .
An immediate function is often executed only once , Because there are no variables to save , After execution , I can't find it .

<> method

Functions can also be called properties of objects , If a function is saved as a property of an object , So we call this function the method of this object .
Calling this function means calling the method of the object (method), Compared with the method , He's just a name difference , There is no other difference .
Function examples :
// Call function fn()
Method example :
// Call method obj.fn();
If it's direct fn(), That means it's a function call , If it turns out to be xx.fn(), That means it's a method call .

Technology
©2020 ioDraw All rights reserved
Swing actual combat Understanding closure about vue in el-date-picker type=daterange The problem of date not echoing Ubuntu 18.04 swap Partition expansion Snake code --c Language Edition visual c++6.0 open 【Golang Basic series 10 】Go language On conditional sentences ifString class —— summary ,String The nature of , Memory resolution , Commonly used APIAdobe Illustrator Publish native support Apple Silicon Test version of the software study java My first class antd table sort