0
is there print() in JS?
I'm doing a JS exercise and I'm supposed to print the answer and there is a "print()" code already. But when I put a variable in there, it's error. And when I tried in code playground, when I run the code it shows a tab where I can print the result in the screen. Here - https://code.sololearn.com/Wx4M4GjBo0uq It's easier if I could just document.write or console.log the output so idk about this print stuff. Is this a bug? And is there a "print()" in javascript? I thought that's for python
4 Respuestas
+ 1
Yes there is window.print();
But it used to print data on the real printer
More:
https://developer.mozilla.org/en-US/docs/Web/API/Window/print
Use console.log(); to print something in the console
and document.write() to display text to the web page.
0
Yes there is a print( ) method under `window`. But it wasn't for printing anything on document or JS log. It rather allows page printing, to an actual printer device.
https://developer.mozilla.org/en-US/docs/Web/API/Window/print
0
J4red
Yes there is a print() function in JS but it's a function of window object
So window.print()
this function is used to print contents
But to display content on browser use document.write()
And to display content on console use
console.log()
- 1
J4red
for debugging, use console.log
let a = "Hi"
console.log(a)
then go to the output tab to view the result.