how to write in console javascript code example

Example 1: javascript log to console

const varName = 'this variable';

console.log(varName);

Example 2: how to use js console log

console.log('string');

Example 3: html console text

<script>
  console.log('%c text', 'background:---; color:---; font-size:---;');
</script>

Example 4: what is console in javascript

var str = "Howdy GeeksforGeeks"
var geek = {
  book: "harrypotter",
  price: "2000"
};
var geek2 = [10, 20, 30];
console.log(str);
console.dir(str);
console.dir(geek);
console.log("geek (log) = ", geek);
console.dir(geek2);
console.log("geek2 (log) = ", geek2);

// Prints only string as dir() takes 
// only one parameter. 
console.dir("geek2 (dir) = ", geek2);

Example 5: console javascript

console.log(variable)

Tags:

Java Example