I want to run a Javascript console on top of V8. How do I do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
V8 is easy to build and does not come with the Java VM overhead from Mozilla’s standalone Javascript interpreter. Luckily, V8 ships with code for building a console. Here is how to build this:
Now, we have a standalone binary called
v8-shell.Running the console:
$> ./v8-shell V8 version 2.0.2 > var x = 10; > x 10 > function foo(x) { return x * x; } > foo function foo(x) { return x * x; } > quit()Executing Javascript from the command line:
$> ./v8-shell -e 'print("10*10 = " + 10*10)' 10*10 = 100Many more features are documented in the help: