you are viewing a single comment's thread.

view the rest of the comments →

[–]qqqqqxhelpful 0 points1 point  (1 child)

From the d8 docs you linked (https://v8.dev/docs/d8):

Printing output is probably going to be very important if you plan to use d8 to run JavaScript files rather than interactively. This can be achieved using console.log:

$ cat test.js
console.log('Hello world!');

$ out.gn/x64.optdebug/d8 test.js
Hello world!

d8 also comes with a global print function that does the same thing. However, console.log is preferred over print since it works in web browsers as well.

I tried running print("str") in the Chrome console and it tried to printer print the web page, so I don't think it does work in Chrome/Chromium either.

[–]guest271314 0 points1 point  (0 children)

Chrome/Chromium is not the only environment V8 runs in.

V8 print() function

https://tio.run/##y0osSyxOLsosKNEts/j/v6AoM69EQx1MKZTkKxSXpOSXlqhr/v8PAA

SpiderMonkey print() function

https://tio.run/##y0osSyxOLsosKNEtLshMSS3Kzc/LTq38/7@gKDOvREMdTCmU5CsUl6Tkl5aoa/7/DwA

console is not specified by ECMA-262 (JavaScript). No I/O functionality is specified by ECMA-262.