Array.prototype.flat ()
method can flatten the nested array into flattening
into one-dimensional array
, accept a number as several layers of expansion, and defaults to layer 1
. If you expand no matter how many layers are nested, you can pass in a Infinity
.
function g1() {
return 1
}
function fn1() {
return g1()
}
fn1
function calls another function in the last step G1
function calls itself, which is called recursion. If the tail calls itself, it is called tail recursion.
so the question is, how do you use tail recursion to optimize the above recursive function?
I"m a little stupid. I can"t figure it out for the time being. So please share your thoughts
.problem description
the environmental background of the problems and what methods you have tried
related codes
/ / Please paste the code text below (do not replace the code with pictures)