| Viewed 36 times

How to print to console in javascript


I need to print variable value in javascript like array

1 Answer
Mohammad Qandeel
Answered
5

There are a lot of ways to print to console in javascript, based on the type of output

  • console.log()    -> Prints a message to the Console.
  • console.info()   -> Prints a message to the Console.
  • console.error() -> Prints object to the Console, formats it as an error, and includes a stack trace.
  • console.table() -> Prints an array of objects as a table.

 

 to print the text just write it within Quotation mark like 

console.log("text") // text

or you can print a variable instead like

let v = 5;
console.log(v); //5

 

Example

console.log("var")
console.info("var")
console.error("var")
console.table([1,2,3])


Related Questions