Share your repls and programming experiences

← Back to all posts
JavaScript interpreter in four lines of code!
Seven7Four4 (20)

I wrote a JavaScript interpreter in JavaScript itself (and yes, the NPM package is mine). With the interpreter, you can simply interpret JavaScript in four lines of code!

Comments
hotnewtop
JasonStinson (0)

[ redacted by moderators for advertising ]

RayhanADev (2596)

Interesting... does this run in a separated process (like spawn_child) or does it run with access to the upper level? What differentiates it from eval()? Kewl project!

Seven7Four4 (20)

@RayhanADev Thanks! Basically, instead of using eval(), it uses the NodeJS VM module. When you use the "interpret" function, it uses the script as the context. You can also use require inside of it, since require in the interpreter is the same as NodeJS's "require".

RayhanADev (2596)

@Seven7Four4 niceeee. That's really cool dude, good luck!

Seven7Four4 (20)

@RayhanADev it kinda feels like an accomplishment lol