How does this complex recursive code work?
问题 I am trying to understand this recursion. I know how recursion works in factorial function but when it gets to this complex recursion like this I am confused. The most confusing part to me is this code str.split('').map( (char, i) => permutations( str.substr(0, i) + str.substr(i + 1) )map( p => char + p)) First, with "abc" , say, it will split into ["a","b","c"] and go through the map function, then go through the second map function to wrap each return with a , b , c , respectively. However,