If you’re using MacBook.
- Set up node.js in your system and open up the terminal.
- Navigate to the directory, where the js file is saved.
- To execute run node
- Install the Code Runner Extension.
- Open Chrome on your computer.
- Click. Settings.
- Click Privacy and security.
- Click Site settings.
- Turn on Allowed (recommended).
Press Command+Option+J (Mac) or Control+Shift+J (Windows, Linux, Chrome OS) to open the Console, right here on this very page.
- open terminal,
- create an empty file: touch script.js ,
- edit file and add a simple function: var add = (a, b) => a + b; console. log(add(5, 10));
- run script using node script. js command,
- the output should be 15 .
- console. log() …
- console. error() …
- console.info() This console command is especial useful to output information to the console. …
- console. table() …
- console. assert() …
- console. clear() …
- & 8. console. …
- console.warn() Logging warnings in the console should be easy!
To try it, complete the following actions.
- Open the Console. Select Control + Shift + J (Windows, Linux) or Command + Option + J (macOS).