Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Remember! Arrays are objects too 🤠solution in Creative category for Easy Unpack by danielsan
/**
* This is my real solution, but if I submit it as an arrow function it is not working
* So, I added the function as a regular one just so it calls my realSolution
**/
const realSolution = ({0:a,2:b,length,[length-2]:c}: any[]): any[] => [a,b,c]
/** I think most people are going to do something like this: */
const commonEasyUnpack = e => [e[0],e[2],e[e.length-2]]
/** Here is a way for not having to do e.length - 2 */
const IdontWantToDoMathEasyUnpack = (e,[f,,t]=e,) => [f,t,e.reverse()[1]]
function easyUnpack(values: any[]): any[] { return realSolution(values) }
April 21, 2020
Comments: