1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 4 <Head>5 <MetaCharSet= "UTF-8">6 <Metaname= "Viewport"content= "Width=device-width, initial-scale=1.0">7 <Metahttp-equiv= "X-ua-compatible"content= "Ie=edge">8 <title>Document</title>9 </Head>Ten One <Body> A - </Body> - <Script> the Const Rules= [{ - match:function(A, B, c) { - Console.log (555); - }, + Action:function(A, B, c) { - Console.log (555); + } A }, { at match:function(A, B, c) { - Console.log (666); - }, - Action:function(A, B, c) { - Console.log (666); - } in }, { - match:function(A, B, c) { to Console.log (777); + }, - Action:function(A, B, c) { the Console.log (777); * } $ }]Panax Notoginseng - functionDemo (A, B, c) { the for(Let I= 0; I<rules.length; I++) { + if(Rules[i].match (A, B, c)) { A returnRules[i].action (A, B, c) the } + } - } $ $ Demo (A, B, d); - </Script> - the </HTML>
An array of responsibility chains for JS conditional statements