Home > Web Front-end > JS Tutorial > body text

An example of JavaScript recursive implementation of reversing array string_javascript skills

WBOY
Release: 2016-05-16 16:34:06
Original
1361 people have browsed it
  <!DOCTYPE html> 
  <html> 
  <head> 
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
  <title>每天一个JavaScript实例-递归实现反转数组字符串</title> 
  <script> 
  var func = function(x,indx,str){ 
    return indx == 0 &#63; str : func(x,--indx,(str +=" " + x[indx]));; 
    } 
  var arr = new Array("apple","banna","orange","apple2","apple3"); 
  var arr1 = arr.slice(0) 
  var arr3 = func(arr1,arr1.length,""); 
  var arr2 = arr.slice(0).reverse(); 
  console.log(arr2); 
  console.log(arr); 
  console.log(arr3); 
   
  </script> 
  </head> 
   
  <body> 
   
  <div id = "date"> 
  </div> 
   
  </body> 
  </html> 
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template