Comment

Comment by antigonemerlin

It occurs to me that metaprogramming looks awfully familiar in JavaScript.

    function process_item(item, action)
    {
        item[action]();
    }
(Also similarly forgetting the guard statement).

Probably not great code, but still.

Since there are no classes in JS and everything is an object, you technically have complete control over such 'classes' and 'methods'. This is probably why people keep trying on turning JS into a different and saner language, or better yet, are using another language entirely like TS. Which is a shame, because it's kind of fun to dynamically generate new functions on the fly and having complete freedom to do anything you want.

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton