[v8-users] NEWBIE Question: How can shell.exe run JavaScript's alert function ?

52 views
Skip to first unread message

Matthew

unread,
Jun 8, 2011, 9:46:35 AM6/8/11
to v8-users
I compiled \V8\samples\shell.cc into shell.exe, and know shell.exe can
execute string by the way below,
Usage:
shell [options] -e string

However, when I run JavaScript's alert() function, the following error
is threw,
--------------
shell.exe -e alert("123")
unnamed:1: ReferenceError: alert is not defined
alert(123)
^
ReferenceError: alert is not defined
at unnamed:1:1
--------------

I don't know why shell.exe can't recognize alert() function. After
all, V8 is a JavaScript engine, and the alert() function is a built-in
JavaScript function.

Bryan White

unread,
Jun 8, 2011, 10:05:25 AM6/8/11
to v8-u...@googlegroups.com
> I don't know why shell.exe can't recognize alert() function. After
> all, V8 is a JavaScript engine, and the alert() function is a built-in
> JavaScript function.
>

alert() is a browser function, not a built in language function. In
particular, alert() makes little sense in the context of a command
line app run with not GUI available.


--
Bryan White

Mikhail Naganov

unread,
Jun 8, 2011, 2:53:55 PM6/8/11
to v8-u...@googlegroups.com, mathe...@gmail.com
shell provides "print" functions which prints to stdout.

> --
> v8-users mailing list
> v8-u...@googlegroups.com
> http://groups.google.com/group/v8-users
>

Reply all
Reply to author
Forward
0 new messages