DEV Community

loading...

Discussion on: Why i hate Javascript

ginsburgnm profile image
Noah Ginsburg

I mean everything in python is a function. I'm not positive what you mean by JavaScript's function construct. But.

In python you can effectively make classes by just embedding function definitions.
You can generate functions programmatically by just modifying the global namespace (it's gross but you can do it, so use only when needed). You can get funky JavaScript like function definitions
Such as:

const sum = new Function('a', 'b', 'return a + b');

by using eval though you shouldn't, because that's gross even in JavaScript and evalis generally a bad idea.

Thread Thread
jwp profile image
John Peters

Nice.

The concept of what Eval does has been around for 50 years or more. E.g. the mainframe language Rexx had an Eval statement. For me, I wouldn't ever say eval is a bad idea as ultimately it's a pseudo run time compiler transforming strings into executable statements. This ability in the right hands is really powerful.

There are rare problems where use of Eval like constructs are true lifesavers.