Very cool indeed. I would implement it as a React component - and then in any view just have to
<Javascript>
[1,2,3].map((n) => (n+1))
</Javascript>
But the of course requires you to implement the page using react, which isn't what everyone is doing.