How to Print to Console in Javascript
Question
Share
Sign Up to our social questions and Answers to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers to ask questions, answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are various ways to to console info.
Here are some important methods of console API
console.log()
console.clear()
console.error()
let num1 = 10, num2 = 0; if (num2 !== 0) { console.log(num1 / num2); } else { console.error("divided by 0"); }console.assert()
console.table() :
const arr = ["a", "b", "c", "d", "e"]; console.table(arr); const user = { name: "Henry", id: "iuA98", age: 22 } console.table(user); o/p: user info in table formatconsole.time() and console.timeEnd()