(no title)
antigonemerlin | 2 years ago
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.