1stDibs.com interview question

Recursively flatten a nested hash in JavaScript. Explain the difference between classical and prototypal inheritance. Code runtime optimization