|
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>每天一個JavaScript實例-遞歸實現(xiàn)反轉(zhuǎn)數(shù)組字符串</title> <script> var func = function(x,indx,str){ return indx == 0 ? 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>
JavaScript技術(shù):一個JavaScript遞歸實現(xiàn)反轉(zhuǎn)數(shù)組字符串的實例,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。