The recursive function to get the value of each item in the array

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>递归调用函数获取数组</title>
</head>
<body>
    <script>
        var arr = ['a','b','C ' , ' D ' , . 1 , . 3 , . 5 , ' E ' , ' F ' , . 9 ]; 

        ( function getArr (I) {     // recursive call the function to get a value for the array of similar loop 
            IF (I == ARR. length) return  to false ;   // Analyzing method i == array length out 
            the console.log (ARR [I]);     // values for each array 

            IF ( typeof ARR [I] ==  ' Number ' ) {  // judgment data types 
                the console.log ( ' Digital Type: ' , ARR [I]) 
            } 

            getArr (I + . 1 ); // recursive call 
        }) ( 0 )    
     </ Script > 
</ body > 
</ HTML >

 

Guess you like

Origin www.cnblogs.com/hs610/p/12033588.html