JavaScript Console Object and Methods



A Javascript console object is a global object that provides access to the browser's debugging console.
Most of us have used console.log() to print messages to the console. but there are many other methods that we can use to debug code easily.


List of JavaScript Console Methods


  1. console.log();
    • Logs a message to the console.
    • This method can print strings, numbers, arrays, and objects.
    console. log("Hello World");
  2. console.info();
    • It is used to display a message to the browser console.
    • This is very similar to console.log(); but it is used by developers for permanent messages to output to the console in their code.
    console. info("This is an information from sugu");
  3. console.warn();
  4. It's used to print warning messages. It'll print a colored(yellow) warning message, commonly used to indicate that something is not quite right.

    console. warn("Hello World");
  5. console.error();
  6. It's used to print error messages. It'll print a colored(red) error message, commonly used to indicate that something has gone wrong.

    console. error("Hello World something went wrong");
  7. console.count();
  8. It's used to print the number of times it's called. It's useful to see how many times a function is called.

    const exec = ( label) =>console.count(label);

    exec(); // default: 1
    exec(); // default: 1
  9. console.assert();
  10. It's used to print an error message if the assertion fails. It's useful to check if some condition is true or not.

    let a = 20);
    let b = 3);
    console .assert (b > a);
  11. Time, Timelog and TimeEnd
  12. This method is used to start a timer to track the logs in the browser.
    console.time(); method is used to start the timer and console.timeEnd(); to end the timer or to stop the timer.
    And the console.timeLog(); is used to log the current value of the timer.

    console. time (" answer time "); //other block of codes
    console. timeLog (" answer time "); //other block of codes
    console. timeEnd (" answer time ");
  13. Group and GroupEnd
  14. It's used to print a group of messages. It's useful to group messages together.

    console.group("USER API")
    console.log("Name: syam")
    console.log("Age: 26")
    console.groupEnd()
    console.group("Product API")
    console.log("Name: Machine Gun")
    console.log("Price: 150000")
    console.groupEnd()
  15. console.table();
  16. It's used to print tabular data. It'll help to visualize the data in a table format.

    const user = {
      name: "John",
      age:30,
    };


    console.table(user);
  17. console.clear();
  18. This console method is used to clear the messages from the console.
    This method will clear all the previous logs.

    console.clear();
  19. console.debug();
  20. This method outputs a message to the console with the log-level debug.

    console.debug('This is bug');

Introduction to CSS Part-2 PDF Click here to download

Easy Pickup


  • 1. CSS More Samples
  • 2. CSS Malayalam Classes
  • 3. CSS Malayalam Notes

New Post 



View Post


Acer Predator Neo (2023) Core i7 13700HX 13th Gen







ചന്ദ്രനുശേഷം സൂര്യൻ! അഭിമാനമാകാൻ ആദിത്യാ എല്‍1; ദൗത്യത്തെക്കുറിച്ച് അറിയേണ്ടതെല്ലാം...





മൈക്രോസോഫ്റ്റ് എക്സൽ ഉപയോഗിക്കുന്നുണ്ടോ?, ഇനി മാറ്റം ഇങ്ങനെ......



SYAMRAJ R

Founder and Developer of Mallu Coder Sugu.We provide the best Computer or Programming Related Content With Notes PDF, Amazing Designs, Easy to Readable for Learners.






Welcome to our Web Designing Studio! Stay and learn from here... Follow our social media for new updates