How to run JavaScript in a console environment?

I am trying to follow the examples given here

http://eloquentjavascript.net/chapter2.html

and

print('blah'); 

Saves an attempt to send to a physical printer when launched in a browser. I just need console output.

+4
source share
3 answers

If you need something simple, the Chrome console will let you run JavaScript on the fly. To print text you can use console.log('blah'); And if you want to print several values, you can simply list them as arguments (no concatenation is needed) console.log("a", "b", "c", 1, 2, 3);

You can output it using control-shift i , and then select the console tab on the right. And, of course, FireBug has a similar feature if you are more of a FireFox fan.

enter image description here

+9
source

Almost all modern browsers have developer tools, including a console. Look for developer tools in your browser, then look for the console.

After you find it, you can enter expressions manually or place console.log() in the desired places in your code.

Note. . When you get used to the console, this will replace the need for such an annoying alert(myVar) .

Additional Information

Here you will find a decent overview / guide to using the console: http://anemonesoft.com/os/cottage/doc/tutorial/console.html

+1
source

You can run javascript interactively from the command line. This blog post from ajaxian.com describes how to use the built-in javascript wrappers for Windows and Mac OS. When you feel particularly lazy, you can also enter commands into a browser-based javascript interpreter, like this one .

+1
source

Source: https://habr.com/ru/post/1392781/


All Articles