Skip to content
jfraboni edited this page Jun 26, 2014 · 2 revisions

console.log()

We’ll use node’s console object a lot to print output to the command-line, it looks like this:

#!/usr/bin/env node

console.log("Welcome to our awesome node app!"); // prints: Welcome to our awesome node app!

If you ran this in the node REPL or in an app you’ll see printed to the command line, “Welcome to our awesome node app!”.

When we use console.log(), we are actually executing a function called log on the console object. When ever you see a function name followed by parenthesis, like, someFunctionName(), we are actually invoking or calling that function. The log function takes an Object and will print some evaluated version of that Object.

Printing stuff allows us not only to give feedback to ourselves or users, but also comes in handy as a debugging tool while writing an app. This process of printing values for debugging is called introspection.

© John Fraboni 2014

Clone this wiki locally