Js function call of two common methods to use the introduction

  • 2020-03-30 03:34:37
  • OfStack

A js function


function test(aa){
window.alert(" What you typed is "+aa);
}

Method 1: call directly

Test (" DDDD ");

Method 2: assign a function to a variable

Var ABC = test;

ABC (' China '); // use variables to call functions

Note:

When we write it this way, var ABC =test(" DDDD "); You cannot call a function through the variable ABC.

This way, when test has a return value, it will assign the return value to ABC, and when there is no return value, the value of ABC will be undefine.


Related articles: