4 ms·
An hour to implement a one-liner? const test = toTest => { try { new Function(`return [ ${toTest.replaceAll('(', '[').replaceAll(')', '],')} ]`)(); return true
by tengbretson 4y ago
An hour to implement a one-liner?
const test = toTest => { try { new Function(`return [ ${toTest.replaceAll('(', '[').replaceAll(')', '],')} ]`)(); return true } catch (e) { return false; } }
- lisasays 4y agoSeems like a horrible design choice to implement something so error-prone (and not immediately, visually obvious) as a one-liner -- and involving both dynamic code generation, -and- the awkward and performance-killing use of exception handling as a loop control, no less.