skip to Main Content

What is the difference between console.log and print in javascript? How console.log basically record it and print only display it on the console, what basically happens behind the scene?

I searched it but i am not able to find the accurate answer there is no specified difference, is there anything present in javascript which behaves like print in other languages?

2

Answers


  1. console.log() is used for print logging in the console (stdout), while print or window.print() is used for printing the entire HTML document of the webpage.

    document.getElementById('c').onclick = () =>{
      console.log("Test");
    }
    document.getElementById('p').onclick = () =>{
      print();
    }
    <button id="c">Console.log("Test")</button>
    <button id="p">Print</button>
    Login or Signup to reply.
  2. "print" is not a standard library for JavaScript’s part. But "console.log" is a function for debugging and logging in JavaScript.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search