Two ways to create custom functions


1. Use function keywords to create function named function

Function fn () {/ / FN is a keyword




2. Creation of anonymous function – function expression

Var FN = function (Num) {/ / FN is a variable name, not a function name

//Functions are stored in FN, while values are stored in variables. This is the fundamental difference.

console.log (“I am a function expression”);

console.log (Num); / / num will output test results

Return num; / / the return value will be returned to arr


Var arr = FN (for testing); / / here is the calling function, which will pass the “for testing” argument to the formal parameter num

console.log (ARR); / / arr receive return value output test