← Back to Community
JavaScript interpreter in four lines of code!
Profile icon
Seven7Four4

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!

Voters
Profile icon
Dunce
Profile icon
ch1ck3n
Profile icon
RayhanADev
Profile icon
Seven7Four4
Comments
hotnewtop
Profile icon
JasonStinson

[ redacted by moderators for advertising ]

Profile icon
RayhanADev

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!

Profile icon
Seven7Four4

@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".

Profile icon
RayhanADev

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

Profile icon
realTronsi
Profile icon
RayhanADev

@realTronsi yeah xD.

Profile icon
Seven7Four4

@RayhanADev it kinda feels like an accomplishment lol