JS: Print

By Xah Lee. Date: . Last updated: .

console.log

To print, use console.log

console.log("hello");
// print to browser's console

To see the output of console.log, open Browser Console .

alert("hello");
// bring up a pop-up dialog

console.assert

console.assert(expression)

prints nothing if expression is true. else it prints “Assertion failed”.

console.assert(3 === 3)
// prints nothing
console.assert(3 === 4)
// Assertion failed

we use console.assert often in this tutorial to verify JavaScript behavior.