Ad
  • Custom User Avatar

    If one has a linked list with tens of thousands of records in Javascript, I think that's likely a problem bigger problem than this function blowing out the stack.

    Though, I am disappointed to learn that most browsers haven't implemented tail recursion optimization, even though it was in the ES2015 spec nearly 10 years ago. It's such a boilerplate program optimization, I'd assumed it would have happened by now. Go Safari, I guess.

  • Default User Avatar

    That's a cheating!)

  • Default User Avatar

    That's clever, but it seems can't handle long orders -- stack overflow should happend due to recursion. That's why I won't vote 'Best Practices' but 'Clever'. Anyway, this is clean and pretty fine!