One of the biggest differences between JavaScript and java is that functions are considered as data and can be operated like an object in java. In addition, because js does not perform type check, Arrays can store anything. So I thought about whether to store functions in the array.
Implement the following functions:
After a function is called, it stores itself in an array (parameters are not allowed to be stored)
Then you can use a large function to operate the array and call the function.
Originally, I wanted to use this method to execute the Undo function once (that is, each function stores itself in it. If Undo is used, the last function is removed and the entire queue is executed again ), later I thought it was too troublesome. However, the function array is implemented by pasting JSP
Copy codeThe Code is as follows:
<% @ Page language = "java" contentType = "text/html; charset = ISO-8859-1"
PageEncoding = "ISO-8859-1" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = ISO-8859-1">
<Title> MothedList </title>
</Head>
<Body>
<Input type = "button" onclick = "ff ()"/>
<Script type = "text/javascript">
List = new Array;
F1 = function f1 (flage ){
Alert ("f1 ");
If (flage)
List. push (f1 );
}
F2 = function f1 (flage ){
Alert ("f2 ");
If (flage)
List. push (f2 );
}
Function ff (){
F1 (true );
F2 (true );
F = list. pop ();
F (false );
F = list. pop ();
F ();
}
</Script>
</Body>
</Html>